Spaces:
Build error
Build error
File size: 1,048 Bytes
c181102 2ab4c57 35ce7ef c181102 35ce7ef c181102 35ce7ef c181102 35ce7ef c181102 2ee6475 c181102 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
import streamlit as st
import gradio as gr
from gradio_client import Client
from PIL import Image
fuyu_client = Client("https://adept-fuyu-8b-demo.hf.space/")
def get_caption(image_in):
fuyu_result = fuyu_client.predict(
image_in, # str representing input in 'raw_image' Image component
True, # bool in 'Enable detailed captioning' Checkbox component
fn_index=2
)
# Find the last occurrence of "."
last_period_index = fuyu_result.rfind('.')
# Truncate the string up to the last period
truncated_caption = fuyu_result[:last_period_index + 1]
# print(truncated_caption)
print(f"\n—\nIMAGE CAPTION: {truncated_caption}")
return truncated_caption
image_1 = st.file_uploader("Drag and drop an image here, or click to select one", type=["png", "jpg", "jpeg"])
# Display the uploaded image
if image_1 is not None:
# Read the image
image = Image.open(image_1)
# Display the image
st.image(image, caption="Uploaded Image", use_column_width=True)
get_caption(image)
|