Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
import streamlit as st
|
2 |
from transformers import pipeline
|
3 |
-
from diffusers import DiffusionPipeline
|
4 |
from PIL import Image
|
5 |
import requests
|
6 |
import io
|
@@ -9,7 +9,7 @@ import io
|
|
9 |
image_to_text = pipeline("image-to-text", model="nlpconnect/vit-gpt2-image-captioning")
|
10 |
|
11 |
# Load the text-to-image model
|
12 |
-
text_to_image = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0")
|
13 |
|
14 |
def main():
|
15 |
st.title("Image to Story to Image Converter")
|
@@ -21,22 +21,26 @@ def main():
|
|
21 |
if input_option == "Text":
|
22 |
text_input = st.text_input("Enter the text:")
|
23 |
if st.button("Generate Story and Image") and text_input:
|
24 |
-
generate_image(text_input)
|
|
|
|
|
25 |
|
26 |
# Input URL
|
27 |
elif input_option == "URL":
|
28 |
-
uploaded_file = st.file_uploader("Upload an image file:", type=["jpg", "jpeg", "png"])
|
29 |
-
if uploaded_file is not None:
|
30 |
-
image = Image.open(uploaded_file)
|
31 |
-
st.image(image, caption="Uploaded Image", use_column_width=True)
|
32 |
-
if st.button("Generate Story and Image"):
|
33 |
-
image_text = image_to_text_from_file(uploaded_file)
|
34 |
-
generate_image(image_text)
|
35 |
-
else:
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
|
|
|
|
40 |
|
41 |
def image_to_text_from_file(uploaded_file):
|
42 |
image_bytes = io.BytesIO(uploaded_file.read())
|
|
|
1 |
import streamlit as st
|
2 |
from transformers import pipeline
|
3 |
+
#from diffusers import DiffusionPipeline
|
4 |
from PIL import Image
|
5 |
import requests
|
6 |
import io
|
|
|
9 |
image_to_text = pipeline("image-to-text", model="nlpconnect/vit-gpt2-image-captioning")
|
10 |
|
11 |
# Load the text-to-image model
|
12 |
+
#text_to_image = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0")
|
13 |
|
14 |
def main():
|
15 |
st.title("Image to Story to Image Converter")
|
|
|
21 |
if input_option == "Text":
|
22 |
text_input = st.text_input("Enter the text:")
|
23 |
if st.button("Generate Story and Image") and text_input:
|
24 |
+
#generate_image(text_input)
|
25 |
+
st.success(f'Generated Caption: {text_input}')
|
26 |
+
|
27 |
|
28 |
# Input URL
|
29 |
elif input_option == "URL":
|
30 |
+
#uploaded_file = st.file_uploader("Upload an image file:", type=["jpg", "jpeg", "png"])
|
31 |
+
#if uploaded_file is not None:
|
32 |
+
#image = Image.open(uploaded_file)
|
33 |
+
#st.image(image, caption="Uploaded Image", use_column_width=True)
|
34 |
+
#if st.button("Generate Story and Image"):
|
35 |
+
#image_text = image_to_text_from_file(uploaded_file)
|
36 |
+
#generate_image(image_text)
|
37 |
+
#else:
|
38 |
+
image_url = st.text_input("Enter the image URL:")
|
39 |
+
if st.button("Generate Story and Image") and image_url:
|
40 |
+
image_text = image_to_text_from_url(image_url)
|
41 |
+
#generate_image(image_text)
|
42 |
+
st.success(f'Generated Caption: {image_text}')
|
43 |
+
|
44 |
|
45 |
def image_to_text_from_file(uploaded_file):
|
46 |
image_bytes = io.BytesIO(uploaded_file.read())
|