Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,13 +8,13 @@ from transformers import pipeline
|
|
| 8 |
def img2text(img):
|
| 9 |
image_to_text_model = pipeline("image-to-text",
|
| 10 |
model="Salesforce/blip-image-captioning-base")
|
| 11 |
-
text = image_to_text_model(
|
| 12 |
return text
|
| 13 |
|
| 14 |
# text2story
|
| 15 |
def text2story(text):
|
| 16 |
pipe = pipeline("text-generation", model="pranavpsv/genre-story-generator-v2")
|
| 17 |
-
story_text = pipe(text)[0]['generated_text']
|
| 18 |
return story_text
|
| 19 |
|
| 20 |
# text2audio
|
|
@@ -29,7 +29,7 @@ def text2audio(story_text):
|
|
| 29 |
st.set_page_config(page_title="Your Image to Audio Story",
|
| 30 |
page_icon="🦜")
|
| 31 |
st.header("Turn Your Image to Audio Story")
|
| 32 |
-
uploaded_file = st.file_uploader("Select an Image...")
|
| 33 |
|
| 34 |
|
| 35 |
if uploaded_file is not None:
|
|
|
|
| 8 |
def img2text(img):
|
| 9 |
image_to_text_model = pipeline("image-to-text",
|
| 10 |
model="Salesforce/blip-image-captioning-base")
|
| 11 |
+
text = image_to_text_model(img_path)[0]["generated_text"]
|
| 12 |
return text
|
| 13 |
|
| 14 |
# text2story
|
| 15 |
def text2story(text):
|
| 16 |
pipe = pipeline("text-generation", model="pranavpsv/genre-story-generator-v2")
|
| 17 |
+
story_text = pipe(text, max_length=100)[0]['generated_text']
|
| 18 |
return story_text
|
| 19 |
|
| 20 |
# text2audio
|
|
|
|
| 29 |
st.set_page_config(page_title="Your Image to Audio Story",
|
| 30 |
page_icon="🦜")
|
| 31 |
st.header("Turn Your Image to Audio Story")
|
| 32 |
+
uploaded_file = st.file_uploader("Select an Image...", type=["jpg", "jpeg", "png"])
|
| 33 |
|
| 34 |
|
| 35 |
if uploaded_file is not None:
|