Pawel_Mar commited on
Commit
612b741
·
1 Parent(s): 4e05e43

appilcation should be finished

Browse files
Files changed (2) hide show
  1. app.py +17 -7
  2. requirements.txt +1 -1
app.py CHANGED
@@ -1,12 +1,22 @@
1
  import gradio as gr
2
- from transformers import AutoModel
3
 
4
 
5
- def greet(name):
6
- return "Hello " + name + "!!"
 
 
 
7
 
8
- model = AutoModel.from_pretrained("models/last.pt")
9
- pipe = pipeline("image-segmentation", model = model)
10
- iface = gr.Interface.from_pipeline(pipe)
 
 
 
 
 
 
 
11
  # iface = gr.Interface(fn=greet, inputs="text", outputs="text")
12
- iface.launch()
 
1
  import gradio as gr
2
+ from ultralytics import YOLO
3
 
4
 
5
+ def yoloV8_func(image: gr.inputs.Image = None):
6
+ model_path = "models/last.pt"
7
+ model = YOLO(model_path)
8
+ results = model.predict(image)
9
+ mask_json = results[0].masks.data.tojson()
10
 
11
+ return str(mask_json)
12
+
13
+
14
+ yolo_app = gr.Interface(
15
+ fn=yoloV8_func,
16
+ inputs=gr.inputs.Image(type="filepath", label="Input Image"),
17
+ outputs=gr.Textbox(),
18
+ title="YOLOv8: Custom Instance segmentation on lettuce leafs",
19
+ cache_examples=True,
20
+ )
21
  # iface = gr.Interface(fn=greet, inputs="text", outputs="text")
22
+ yolo_app.launch()
requirements.txt CHANGED
@@ -2,4 +2,4 @@ opencv-python-headless
2
  pandas
3
  ultralytics
4
  Pillow
5
- transformers
 
2
  pandas
3
  ultralytics
4
  Pillow
5
+ gradio