Spaces:
Sleeping
Sleeping
Update app.py
Browse files6 unmodified lines789101112131415161718192021222324256 unmodified linesfrom transformers import pipeline# Generates a caption for the given image using a pre-trained model.def image_to_caption(image_path):imgtocaption = pipeline("image-to-text", model="Salesforce/blip-image-captioning-base")caption = imgtocaption(image_path)[0]['generated_text']return caption# Generates a story for the caption using a pre-trained model.def caption_to_story(text):captiontostory = pipeline("text-generation", model="pranavpsv/genre-story-generator-v2")story = captiontostory(text,max_length=150,min_length=50)[0]['generated_text']return story# Generates an audio for the story.def story_to_audio(text):audio = io.BytesIO()tts = gTTS(text=text, lang='en', slow=False)6 unmodified lines789101112131415161718192021222324256 unmodified linesfrom transformers import pipeline# Generates a caption for the given image using a pre-trained modeldef image_to_caption(image_path):imgtocaption = pipeline("image-to-text", model="Salesforce/blip-image-captioning-base")caption = imgtocaption(image_path)[0]['generated_text']return caption# Generates a story for the caption using a pre-trained modeldef caption_to_story(text):captiontostory = pipeline("text-generation", model="pranavpsv/genre-story-generator-v2")story = captiontostory(text,max_length=150,min_length=50)[0]['generated_text']return story# Generates an audio for the storydef story_to_audio(text):audio = io.BytesIO()tts = gTTS(text=text, lang='en', slow=False)
app.py+3-3