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(
|
| 32 |
# image
|
| 33 |
inputs = processor(image_object, return_tensors="pt").to(device)
|
| 34 |
outputs = model.generate(**inputs)
|
|
@@ -65,6 +65,13 @@ agent = initialize_agent(
|
|
| 65 |
)
|
| 66 |
)
|
| 67 |
|
| 68 |
-
|
| 69 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
|
|
|
|
|
|
|
|
|
| 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 |
)
|
| 66 |
)
|
| 67 |
|
| 68 |
+
import gradio as gr
|
| 69 |
+
def segment(image):
|
| 70 |
+
#pass # Implement your image segmentation model here...
|
| 71 |
+
print(image)
|
| 72 |
+
image_url = image
|
| 73 |
+
|
| 74 |
+
return agent(f"Describe the following image:\n{image_url}").get('output').replace('The response to your last comment is','')
|
| 75 |
|
| 76 |
+
demo = gr.Interface(segment, gr.Image(type="filepath",shape=(200, 200)), "text")
|
| 77 |
+
demo.launch()
|