Spaces:
Sleeping
Sleeping
SarowarSaurav
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -22,11 +22,8 @@ client = ChatCompletionsClient(
|
|
22 |
)
|
23 |
|
24 |
# Define the function to handle the image and get predictions
|
25 |
-
def analyze_leaf_disease(
|
26 |
try:
|
27 |
-
# Convert the uploaded image to a compatible format (e.g., save it locally)
|
28 |
-
image.save("uploaded_image.jpg")
|
29 |
-
|
30 |
# Prepare and send the request to the Azure API
|
31 |
response = client.complete(
|
32 |
messages=[
|
@@ -38,7 +35,7 @@ def analyze_leaf_disease(image):
|
|
38 |
TextContentItem(text="What's the leaf disease in this image?"),
|
39 |
ImageContentItem(
|
40 |
image_url=ImageUrl.load(
|
41 |
-
image_file=
|
42 |
image_format="jpg",
|
43 |
detail=ImageDetailLevel.LOW,
|
44 |
)
|
@@ -58,7 +55,7 @@ def analyze_leaf_disease(image):
|
|
58 |
# Define the Gradio interface
|
59 |
interface = gr.Interface(
|
60 |
fn=analyze_leaf_disease,
|
61 |
-
inputs=gr.Image(type="
|
62 |
outputs="text",
|
63 |
title="Leaf Disease Detector",
|
64 |
description="Upload an image of a leaf, and this tool will identify the disease affecting it.",
|
|
|
22 |
)
|
23 |
|
24 |
# Define the function to handle the image and get predictions
|
25 |
+
def analyze_leaf_disease(image_path):
|
26 |
try:
|
|
|
|
|
|
|
27 |
# Prepare and send the request to the Azure API
|
28 |
response = client.complete(
|
29 |
messages=[
|
|
|
35 |
TextContentItem(text="What's the leaf disease in this image?"),
|
36 |
ImageContentItem(
|
37 |
image_url=ImageUrl.load(
|
38 |
+
image_file=image_path,
|
39 |
image_format="jpg",
|
40 |
detail=ImageDetailLevel.LOW,
|
41 |
)
|
|
|
55 |
# Define the Gradio interface
|
56 |
interface = gr.Interface(
|
57 |
fn=analyze_leaf_disease,
|
58 |
+
inputs=gr.Image(type="filepath", label="Upload an Image of a Leaf"),
|
59 |
outputs="text",
|
60 |
title="Leaf Disease Detector",
|
61 |
description="Upload an image of a leaf, and this tool will identify the disease affecting it.",
|