Spaces:
Runtime error
Runtime error
Commit
•
3ca8cd2
1
Parent(s):
2c71197
Update app.py
Browse files
app.py
CHANGED
@@ -1,82 +1,12 @@
|
|
1 |
-
import sys
|
2 |
-
sys.path.append("pixray/text2image")
|
3 |
-
|
4 |
-
from os import path
|
5 |
-
from PIL import Image
|
6 |
-
from PIL import ImageFont
|
7 |
-
from PIL import Image
|
8 |
-
from PIL import ImageFont
|
9 |
-
from PIL import Image
|
10 |
-
from PIL import ImageFont
|
11 |
-
from PIL import Image
|
12 |
-
from PIL import ImageDraw
|
13 |
-
from PIL import ImageFont
|
14 |
-
from PIL import Image
|
15 |
-
from PIL import ImageFont
|
16 |
-
from PIL import ImageDraw
|
17 |
-
from PIL import ImageDraw
|
18 |
-
from PIL import ImageFont
|
19 |
-
from PIL import ImageDraw
|
20 |
-
from PIL import ImageFont
|
21 |
-
from PIL import ImageDraw
|
22 |
-
from PIL import ImageFont
|
23 |
-
from PIL import ImageDraw
|
24 |
-
from PIL import ImageFont
|
25 |
-
import os
|
26 |
-
import replicate
|
27 |
-
import st
|
28 |
-
## make a catch 404 statement if there is a bug
|
29 |
-
import streamlit.components.v1 as components
|
30 |
-
## now make a streamalit app gui for pixray text2image
|
31 |
-
import streamlit as st
|
32 |
-
import numpy as np
|
33 |
-
import PIL
|
34 |
-
import PIL.Image
|
35 |
-
import PIL.ImageDraw
|
36 |
-
import PIL.ImageFont
|
37 |
-
import PIL.ImageOps
|
38 |
-
def main():
|
39 |
-
import replicate
|
40 |
-
model = replicate.models.get("pixray/text2image")
|
41 |
-
model.predict(prompts=input("Enter text: "))
|
42 |
-
## make a streamlit app
|
43 |
-
|
44 |
-
## fix import replicate
|
45 |
|
46 |
-
## make a streamlit app gui for pixray text2image
|
47 |
-
import streamlit as st
|
48 |
-
import numpy as np
|
49 |
-
import PIL
|
50 |
-
import PIL.Image
|
51 |
-
import PIL.ImageDraw
|
52 |
-
import streamlit.components.v1 as components
|
53 |
-
## now make a streamalit app gui for pixray text2image
|
54 |
import streamlit as st
|
55 |
-
import numpy as np
|
56 |
-
import PIL
|
57 |
-
import PIL.Image
|
58 |
-
import PIL.ImageDraw
|
59 |
-
import PIL.ImageFont
|
60 |
-
import PIL.ImageOps
|
61 |
-
def main():
|
62 |
-
st.title("Pixray Text2Image")
|
63 |
-
st.markdown("""
|
64 |
-
This app converts text to images.
|
65 |
-
""")
|
66 |
-
st.markdown("""
|
67 |
-
**How to use:**
|
68 |
-
1. Enter text in the text box below.
|
69 |
-
2. Click the button to convert text to an image.
|
70 |
-
3. Click the button to save the image.
|
71 |
-
""")
|
72 |
-
text = st.text_area("Enter text here:", "")
|
73 |
-
if st.button("Convert text to image"):
|
74 |
-
image = model.predict(prompts=text)
|
75 |
-
st.image(image, use_column_width=True)
|
76 |
-
if st.button("Save image"):
|
77 |
-
st.write("Saving image...")
|
78 |
-
image.save("image.png")
|
79 |
-
st.success("Image saved.")
|
80 |
|
81 |
-
|
82 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
import streamlit as st
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
+
from text2img import text2img
|
5 |
+
|
6 |
+
st.text("Hello, world!")
|
7 |
+
|
8 |
+
st.text("This is a test GUI for streamlit that uses text2img to make a png file.")
|
9 |
+
|
10 |
+
png = text2img("Hello, world!")
|
11 |
+
|
12 |
+
st.image(png, caption="Hello, world!", use_column_width=True)
|