Update app.py
Browse files
app.py
CHANGED
@@ -28,7 +28,7 @@ import requests
|
|
28 |
from PIL import Image
|
29 |
|
30 |
def describeImage(image_url):
|
31 |
-
image_object = Image.open(image_url).convert('RGB')
|
32 |
# image
|
33 |
inputs = processor(image_object, return_tensors="pt").to(device)
|
34 |
outputs = model.generate(**inputs)
|
@@ -65,14 +65,6 @@ agent = initialize_agent(
|
|
65 |
)
|
66 |
)
|
67 |
|
|
|
|
|
68 |
|
69 |
-
import gradio as gr
|
70 |
-
def segment(image):
|
71 |
-
#pass # Implement your image segmentation model here...
|
72 |
-
print(image)
|
73 |
-
image_url = image
|
74 |
-
|
75 |
-
return agent(f"Describe the following image:\n{image_url}")['output']
|
76 |
-
|
77 |
-
demo = gr.Interface(segment, gr.Image(type="filepath",shape=(200, 200)), "text")
|
78 |
-
demo.launch()
|
|
|
28 |
from PIL import Image
|
29 |
|
30 |
def describeImage(image_url):
|
31 |
+
image_object = Image.open(requests.get(image_url, stream=True).raw).convert('RGB')
|
32 |
# image
|
33 |
inputs = processor(image_object, return_tensors="pt").to(device)
|
34 |
outputs = model.generate(**inputs)
|
|
|
65 |
)
|
66 |
)
|
67 |
|
68 |
+
image_url = 'https://images.unsplash.com/photo-1682228287072-5e23cbffd487?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=987&q=80'
|
69 |
+
agent(f"Please describe the following image:\n{image_url}")
|
70 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|