randomshit11 commited on
Commit
b91cad9
·
verified ·
1 Parent(s): 6e5f902

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -7
app.py CHANGED
@@ -8,10 +8,9 @@ pipe = pipeline("image-classification", "dima806/medicinal_plants_image_detectio
8
  def image_classifier(image):
9
  # Perform image classification
10
  outputs = pipe(image)
11
- results = {}
12
- for result in outputs:
13
- results[result['label']] = result['score']
14
- return results
15
 
16
  # Define app title and description with HTML formatting
17
  title = "<h1 style='text-align: center; color: #4CAF50;'>Image Classification</h1>"
@@ -37,9 +36,7 @@ custom_css = """
37
  """
38
 
39
  # Launch the Gradio interface with custom HTML and CSS
40
- demo = gr.Interface(fn=image_classifier, inputs=gr.Image(type="pil"), outputs="text", title=title, description=description,
41
  theme="gstaff/sketch", css=custom_css,
42
  )
43
  demo.launch()
44
-
45
-
 
8
  def image_classifier(image):
9
  # Perform image classification
10
  outputs = pipe(image)
11
+ # Get the label of the first result
12
+ output_text = outputs[0]['label']
13
+ return output_text
 
14
 
15
  # Define app title and description with HTML formatting
16
  title = "<h1 style='text-align: center; color: #4CAF50;'>Image Classification</h1>"
 
36
  """
37
 
38
  # Launch the Gradio interface with custom HTML and CSS
39
+ demo = gr.Interface(fn=image_classifier, inputs=gr.Image(type="pil"), outputs="textbox", title=title, description=description,
40
  theme="gstaff/sketch", css=custom_css,
41
  )
42
  demo.launch()