kishkath commited on
Commit
4480e8f
·
1 Parent(s): 6f08b1e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +48 -3
app.py CHANGED
@@ -1,3 +1,48 @@
1
- '''
2
- contains the infernce code for fastsam.py
3
- '''
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # '''
2
+ # contains the infernce code for fastsam.py
3
+ # '''
4
+ # import numpy as np
5
+ # import gradio as gr
6
+ # from PIL import Image
7
+ # from ultralytics import FastSAM
8
+ # from ultralytics.models.fastsam import FastSAMPrompt
9
+
10
+ # def inference(image):
11
+
12
+ # model = FastSAM('FastSAM.pt')
13
+
14
+ # ## inference results
15
+ # # Run inference on an image
16
+ # results = model(source, device='cpu', retina_masks=True, imgsz=1024, conf=0.4, iou=0.9)
17
+
18
+ # # Prepare a Prompt Process object
19
+ # prompt_process = FastSAMPrompt(source, results, device='cpu')
20
+
21
+ # # Everything prompt
22
+ # ann = prompt_process.everything_prompt()
23
+
24
+ # # Bbox default shape [0,0,0,0] -> [x1,y1,x2,y2]
25
+ # ann = prompt_process.box_prompt(bbox=[200, 200, 300, 300])
26
+
27
+ # # Text prompt
28
+ # ann = prompt_process.text_prompt(text='a photo of a dog')
29
+
30
+ # # Bbox default shape [0,0,0,0] -> [x1,y1,x2,y2]
31
+ # ann = prompt_process.point_prompt(points=[[200,200]],pointlabel=[1])
32
+ # prompt_process.plot(annotations=ann,output='./')
33
+
34
+
35
+
36
+ # title = "Usage of FastSAM"
37
+ # description = "Implementation of pre-trained fast-sam model for spaces."
38
+
39
+ # demo = gr.Interface(inference,inputs=[gr.Image(shape=(32,32),labels="Input Image"),"checkbox"],
40
+ # outputs = [gr.Image(shape=(32,32),label='Output').style(width=128,height=128)],
41
+ # title = title,
42
+ # description = description)
43
+
44
+ # demo.launch(debug = True)
45
+
46
+
47
+
48
+