Update app.py
Browse files
app.py
CHANGED
@@ -27,18 +27,17 @@ def load_pipelines():
|
|
27 |
model="Salesforce/blip-image-captioning-base",
|
28 |
device=-1 # CPU; set to 0+ for GPU
|
29 |
)
|
30 |
-
# 2) Story-generation pipeline (
|
31 |
storyteller = pipeline(
|
32 |
task="text2text-generation",
|
33 |
-
model="
|
34 |
-
tokenizer="
|
35 |
-
trust_remote_code=True,
|
36 |
device=-1, # CPU; set to 0+ for GPU
|
37 |
-
temperature=0.
|
38 |
top_p=0.9,
|
39 |
-
repetition_penalty=1.
|
40 |
-
no_repeat_ngram_size=
|
41 |
-
max_new_tokens=
|
42 |
)
|
43 |
return captioner, storyteller
|
44 |
|
@@ -49,7 +48,7 @@ uploaded = st.file_uploader("Upload an image:", type=["jpg", "png", "jpeg"])
|
|
49 |
if uploaded:
|
50 |
# Load and display the image
|
51 |
img = Image.open(uploaded).convert("RGB")
|
52 |
-
st.image(img,
|
53 |
|
54 |
# Generate caption
|
55 |
with st.spinner("🔍 Generating caption..."):
|
@@ -94,4 +93,3 @@ if uploaded:
|
|
94 |
# Footer
|
95 |
st.markdown("---\n*Made with ❤️ by your friendly story wizard*")
|
96 |
|
97 |
-
|
|
|
27 |
model="Salesforce/blip-image-captioning-base",
|
28 |
device=-1 # CPU; set to 0+ for GPU
|
29 |
)
|
30 |
+
# 2) Story-generation pipeline (StoryTeller)
|
31 |
storyteller = pipeline(
|
32 |
task="text2text-generation",
|
33 |
+
model="pranavpsv/StoryTeller",
|
34 |
+
tokenizer="pranavpsv/StoryTeller",
|
|
|
35 |
device=-1, # CPU; set to 0+ for GPU
|
36 |
+
temperature=0.7,
|
37 |
top_p=0.9,
|
38 |
+
repetition_penalty=1.2,
|
39 |
+
no_repeat_ngram_size=3,
|
40 |
+
max_new_tokens=150
|
41 |
)
|
42 |
return captioner, storyteller
|
43 |
|
|
|
48 |
if uploaded:
|
49 |
# Load and display the image
|
50 |
img = Image.open(uploaded).convert("RGB")
|
51 |
+
st.image(img, use_column_width=True)
|
52 |
|
53 |
# Generate caption
|
54 |
with st.spinner("🔍 Generating caption..."):
|
|
|
93 |
# Footer
|
94 |
st.markdown("---\n*Made with ❤️ by your friendly story wizard*")
|
95 |
|
|