Karan236 commited on
Commit
cecee6f
1 Parent(s): 622f580
Files changed (3) hide show
  1. app.py +28 -3
  2. index.html +19 -0
  3. requirements.txt +10 -101
app.py CHANGED
@@ -1,4 +1,29 @@
1
- import streamlit as st
 
2
 
3
- x = st.slider('Select a value')
4
- st.write(x, 'squared is', x * x)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from flask import Flask, render_template, request
2
+ from transformers import Text2ImagePipeline
3
 
4
+ app = Flask(__name__)
5
+
6
+ # Load the Hugging Face model for text-to-image generation
7
+ text_to_image = Text2ImagePipeline(model="text2img")
8
+
9
+ @app.route('/')
10
+ def home():
11
+ return render_template('index.html')
12
+
13
+ @app.route('/generate', methods=['POST'])
14
+ def generate():
15
+ if request.method == 'POST':
16
+ # Get text input from the form
17
+ text = request.form['text']
18
+
19
+ # Generate image from text
20
+ image = text_to_image(text)
21
+
22
+ # Save the generated image (for simplicity, you can send it directly to the user)
23
+ # You can save it to a temporary file or memory depending on your needs
24
+ image.save("static/generated_image.png")
25
+
26
+ return render_template('index.html', generated=True)
27
+
28
+ if __name__ == '__main__':
29
+ app.run(debug=True)
index.html ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Strimlet</title>
7
+ </head>
8
+ <body>
9
+ <h1>Strimlet</h1>
10
+ <form action="/generate" method="post">
11
+ <textarea name="text" placeholder="Enter your text here" rows="4" cols="50"></textarea><br>
12
+ <input type="submit" value="Generate Image">
13
+ </form>
14
+ {% if generated %}
15
+ <h2>Generated Image:</h2>
16
+ <img src="{{ url_for('static', filename='generated_image.png') }}" alt="Generated Image">
17
+ {% endif %}
18
+ </body>
19
+ </html>
requirements.txt CHANGED
@@ -1,101 +1,10 @@
1
- absl-py
2
- accelerate
3
- aiohttp
4
- aiosignal
5
- astunparse
6
- async-timeout
7
- attrs
8
- certifi
9
- charset-normalizer
10
- chex
11
- colorama
12
- datasets
13
- diffusers
14
- dill
15
- etils
16
- filelock
17
- flatbuffers
18
- flax
19
- frozenlist
20
- fsspec
21
- gast
22
- google-pasta
23
- graphviz
24
- grpcio
25
- h5py
26
- huggingface-hub
27
- idna
28
- importlib_metadata
29
- importlib_resources
30
- inquirerpy
31
- invisible-watermark
32
- jax
33
- jaxlib
34
- Jinja2
35
- keras
36
- libclang
37
- Markdown
38
- markdown-it-py
39
- MarkupSafe
40
- mdurl
41
- ml-dtypes
42
- mpmath
43
- msgpack
44
- multidict
45
- multiprocess
46
- namex
47
- nest-asyncio
48
- networkx
49
- numpy
50
- opencv-python
51
- opt-einsum
52
- optax
53
- optree
54
- orbax-checkpoint
55
- packaging
56
- pandas
57
- pfzy
58
- pillow
59
- prompt-toolkit
60
- protobuf
61
- psutil
62
- pyarrow
63
- pyarrow-hotfix
64
- pydot
65
- Pygments
66
- pyparsing
67
- python-dateutil
68
- pytz
69
- PyWavelets
70
- PyYAML
71
- regex
72
- requests
73
- rich
74
- safetensors
75
- scipy
76
- six
77
- sympy
78
- tensorboard
79
- tensorboard-data-server
80
- tensorflow
81
- tensorflow-intel
82
- tensorflow-io-gcs-filesystem
83
- tensorstore
84
- termcolor
85
- tf_keras
86
- tokenizers
87
- toolz
88
- torch
89
- torchaudio
90
- torchvision
91
- tqdm
92
- transformers
93
- typing_extensions
94
- tzdata
95
- urllib3
96
- wcwidth
97
- Werkzeug
98
- wrapt
99
- xxhash
100
- yarl
101
- zipp
 
1
+ blinker==1.7.0
2
+ click==8.1.7
3
+ colorama==0.4.6
4
+ Flask==3.0.2
5
+ importlib_metadata==7.1.0
6
+ itsdangerous==2.1.2
7
+ Jinja2==3.1.3
8
+ MarkupSafe==2.1.5
9
+ Werkzeug==3.0.1
10
+ zipp==3.18.1