Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,12 +1,27 @@
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
from PIL import Image
|
| 3 |
import time
|
| 4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
# App title
|
| 6 |
-
st.title("
|
| 7 |
|
| 8 |
# Write some text
|
| 9 |
-
st.write("
|
| 10 |
|
| 11 |
# File uploader for image and audio
|
| 12 |
uploaded_image = st.file_uploader("Upload an image", type=["jpg", "jpeg", "png"])
|
|
|
|
| 1 |
+
# import part
|
| 2 |
import streamlit as st
|
| 3 |
from PIL import Image
|
| 4 |
import time
|
| 5 |
|
| 6 |
+
from transformers import pipeline
|
| 7 |
+
|
| 8 |
+
def generate_image_caption(image_path):
|
| 9 |
+
"""Generates a caption for the given image using a pre-trained model."""
|
| 10 |
+
img2caption = pipeline("image-to-text", model="Salesforce/blip-image-captioning-base")
|
| 11 |
+
result = img2caption(image_path)
|
| 12 |
+
return result[0]['generated_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 |
# App title
|
| 21 |
+
st.title("Assignment")
|
| 22 |
|
| 23 |
# Write some text
|
| 24 |
+
st.write("Image to Story")
|
| 25 |
|
| 26 |
# File uploader for image and audio
|
| 27 |
uploaded_image = st.file_uploader("Upload an image", type=["jpg", "jpeg", "png"])
|