Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,7 +2,7 @@ import streamlit as st
|
|
| 2 |
import io
|
| 3 |
from PIL import Image
|
| 4 |
import easyocr
|
| 5 |
-
from transformers import pipeline
|
| 6 |
|
| 7 |
# Create a text2text-generation pipeline with the "t5-base" model
|
| 8 |
pipe = pipeline("text2text-generation", model="t5-base")
|
|
@@ -26,7 +26,8 @@ if uploaded_file is not None:
|
|
| 26 |
|
| 27 |
if extracted_text:
|
| 28 |
# Use the pipeline to generate a story based on the extracted text
|
| 29 |
-
story_prompt = f"
|
|
|
|
| 30 |
story = pipe(story_prompt, max_length=300, do_sample=True)[0]["generated_text"]
|
| 31 |
st.markdown("**Story:**")
|
| 32 |
st.markdown(story)
|
|
|
|
| 2 |
import io
|
| 3 |
from PIL import Image
|
| 4 |
import easyocr
|
| 5 |
+
from transformers import pipeline, set_seed
|
| 6 |
|
| 7 |
# Create a text2text-generation pipeline with the "t5-base" model
|
| 8 |
pipe = pipeline("text2text-generation", model="t5-base")
|
|
|
|
| 26 |
|
| 27 |
if extracted_text:
|
| 28 |
# Use the pipeline to generate a story based on the extracted text
|
| 29 |
+
story_prompt = f"Once upon a time, in a world where '{extracted_text}',"
|
| 30 |
+
set_seed(42) # Set a seed for reproducibility
|
| 31 |
story = pipe(story_prompt, max_length=300, do_sample=True)[0]["generated_text"]
|
| 32 |
st.markdown("**Story:**")
|
| 33 |
st.markdown(story)
|