Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,10 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import gradio as gr
|
| 3 |
from gradio_client import Client
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
fuyu_client = Client("https://adept-fuyu-8b-demo.hf.space/")
|
| 7 |
def get_caption(image_in):
|
|
@@ -23,15 +26,44 @@ def get_caption(image_in):
|
|
| 23 |
|
| 24 |
return truncated_caption
|
| 25 |
|
| 26 |
-
image_1 = st.file_uploader("Drag and drop an image here, or click to select one", type=["png", "jpg", "jpeg"])
|
| 27 |
|
| 28 |
# Display the uploaded image
|
| 29 |
-
if image_1 is not None:
|
| 30 |
# Read the image
|
| 31 |
-
|
| 32 |
-
|
| 33 |
# Display the image
|
| 34 |
-
st.image(image, caption="Uploaded Image", use_column_width=True)
|
| 35 |
-
get_caption(image)
|
| 36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import gradio as gr
|
| 3 |
from gradio_client import Client
|
| 4 |
+
import re
|
| 5 |
+
import torch
|
| 6 |
+
from transformers import pipeline
|
| 7 |
+
|
| 8 |
|
| 9 |
fuyu_client = Client("https://adept-fuyu-8b-demo.hf.space/")
|
| 10 |
def get_caption(image_in):
|
|
|
|
| 26 |
|
| 27 |
return truncated_caption
|
| 28 |
|
| 29 |
+
#image_1 = st.file_uploader("Drag and drop an image here, or click to select one", type=["png", "jpg", "jpeg"])
|
| 30 |
|
| 31 |
# Display the uploaded image
|
| 32 |
+
#if image_1 is not None:
|
| 33 |
# Read the image
|
| 34 |
+
# image = Image.open(image_1)
|
| 35 |
+
|
| 36 |
# Display the image
|
| 37 |
+
#st.image(image, caption="Uploaded Image", use_column_width=True)
|
| 38 |
+
#get_caption(image)
|
| 39 |
|
| 40 |
+
def infer(image_in):
|
| 41 |
+
gr.Info("Getting image caption with Fuyu...")
|
| 42 |
+
user_prompt = get_caption(image_in)
|
| 43 |
+
write(user_prompt)
|
| 44 |
+
return user_prompt
|
| 45 |
|
| 46 |
+
with gr.Blocks(css=css) as demo:
|
| 47 |
+
with gr.Column(elem_id="col-container"):
|
| 48 |
+
gr.HTML(f"""
|
| 49 |
+
<h2 style="text-align: center;">LLM Agent from a Picture</h2>
|
| 50 |
+
<p style="text-align: center;">{description}</p>
|
| 51 |
+
""")
|
| 52 |
+
|
| 53 |
+
with gr.Row():
|
| 54 |
+
with gr.Column():
|
| 55 |
+
image_in = gr.Image(
|
| 56 |
+
label = "Image reference",
|
| 57 |
+
type = "filepath",
|
| 58 |
+
elem_id = "image-in"
|
| 59 |
+
)
|
| 60 |
+
submit_btn = gr.Button("Make LLM system from my pic !")
|
| 61 |
+
submit_btn.click(
|
| 62 |
+
fn = infer,
|
| 63 |
+
inputs = [
|
| 64 |
+
image_in
|
| 65 |
+
],
|
| 66 |
+
outputs =[
|
| 67 |
+
result
|
| 68 |
+
]
|
| 69 |
+
)
|