nexusbert commited on
Commit
a7baf7d
·
1 Parent(s): b3364e3

Remove comments and docstrings

Browse files
Files changed (1) hide show
  1. app.py +0 -10
app.py CHANGED
@@ -1,25 +1,16 @@
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
- # Load the model pipeline
5
  MODEL_NAME = "nexusbert/tomato-disease-vit"
6
  classifier = pipeline("image-classification", model=MODEL_NAME)
7
 
8
  def classify_tomato(image):
9
- """
10
- Classify tomato disease from an image.
11
- Returns formatted prediction results.
12
- """
13
  if image is None:
14
  return "Please upload an image"
15
 
16
- # Get predictions
17
  predictions = classifier(image)
18
-
19
- # Sort by confidence
20
  predictions = sorted(predictions, key=lambda x: x['score'], reverse=True)
21
 
22
- # Format output
23
  result = "## 🍅 Classification Results\n\n"
24
  result += f"**Top Prediction:** {predictions[0]['label']}\n\n"
25
  result += f"**Confidence:** {predictions[0]['score']*100:.2f}%\n\n"
@@ -29,7 +20,6 @@ def classify_tomato(image):
29
 
30
  return result
31
 
32
- # Create Gradio interface using simple Interface API
33
  demo = gr.Interface(
34
  fn=classify_tomato,
35
  inputs=gr.Image(type="pil", label="Upload Tomato Leaf Image"),
 
1
  import gradio as gr
2
  from transformers import pipeline
3
 
 
4
  MODEL_NAME = "nexusbert/tomato-disease-vit"
5
  classifier = pipeline("image-classification", model=MODEL_NAME)
6
 
7
  def classify_tomato(image):
 
 
 
 
8
  if image is None:
9
  return "Please upload an image"
10
 
 
11
  predictions = classifier(image)
 
 
12
  predictions = sorted(predictions, key=lambda x: x['score'], reverse=True)
13
 
 
14
  result = "## 🍅 Classification Results\n\n"
15
  result += f"**Top Prediction:** {predictions[0]['label']}\n\n"
16
  result += f"**Confidence:** {predictions[0]['score']*100:.2f}%\n\n"
 
20
 
21
  return result
22
 
 
23
  demo = gr.Interface(
24
  fn=classify_tomato,
25
  inputs=gr.Image(type="pil", label="Upload Tomato Leaf Image"),