KaraAgroAI commited on
Commit
8b8ad4e
1 Parent(s): 3299010

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +40 -0
  2. requirements.txt +3 -0
app.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # import gradio as gr
2
+
3
+ # gr.Interface.load("models/KaraAgroAI/CADI-AI").launch()
4
+
5
+ import gradio as gr
6
+ # import cv2
7
+ # import requests
8
+ # import os
9
+ from PIL import Image
10
+ import torch
11
+ import ultralytics
12
+
13
+ model = torch.hub.load("ultralytics/yolov5", "custom", path="yolov5_0.65map_exp7_best.pt",
14
+ force_reload=False)
15
+
16
+ model.conf = 0.20 # NMS confidence threshold
17
+
18
+ path = [['img/test-image.jpg']]
19
+
20
+ def show_preds_image(im):
21
+
22
+ results = model(im) # inference
23
+ return results.render()[0]
24
+
25
+ inputs_image = [
26
+ gr.components.Image(type="filepath", label="Input Image"),
27
+ ]
28
+ outputs_image = [
29
+ gr.components.Image(type="filepath", label="Output Image"),
30
+ ]
31
+ interface_image = gr.Interface(
32
+ fn=show_preds_image,
33
+ inputs=inputs_image,
34
+ outputs=outputs_image,
35
+ title="Cashew Disease Identification with AI",
36
+ examples=path,
37
+ cache_examples=False,
38
+ )
39
+
40
+ interface_image.launch()
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ torch
2
+ ultralytics
3
+ pillow