sahal-mulki commited on
Commit
a47f7fe
1 Parent(s): 4668af9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -14
app.py CHANGED
@@ -1,15 +1,16 @@
1
  import gradio as gr
2
- import socket
3
-
4
- def next_free_port( port=1024, max_port=65535 ):
5
- sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
6
- while port <= max_port:
7
- try:
8
- sock.bind(('', port))
9
- sock.close()
10
- return port
11
- except OSError:
12
- port += 1
13
- raise IOError('no free ports')
14
-
15
- gr.Interface.load("models/sahal-mulki/spotting-diffusion").launch(next_free_port())
 
 
1
  import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ classifier = pipeline("image-classification", model="sahal-mulki/spotting-diffusion")
5
+
6
+ def predict(image):
7
+ predictions = pipeline(image)
8
+ return {p["label"]: p["score"] for p in predictions}
9
+
10
+
11
+ gr.Interface(fn=classify_image,
12
+ inputs=gr.inputs.Image(shape=(256, 256)),
13
+ outputs=gr.outputs.Label(num_top_classes=2),
14
+ # examples=["banana.jpg", "car.jpg"],
15
+ theme="default",
16
+ css=".footer{display:none !important}").launch()