Spaces:
Build error
Build error
File size: 1,050 Bytes
c181102 2ab4c57 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 |
import streamlit as st
import gradio as gr
from gradio_client import Client
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
uploaded_image = st.file_uploader("Drag and drop an image here, or click to select one", type=["png", "jpg", "jpeg"])
# Display the uploaded image
if uploaded_image is not None:
# Read the image
image = Image.open(uploaded_image)
# Display the image
st.image(image, caption="Uploaded Image", use_column_width=True)
st.write(truncated_caption)
|