freddyaboulton HF staff commited on
Commit
21e1e8a
·
verified ·
1 Parent(s): 145c839

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +5 -11
app.py CHANGED
@@ -5,7 +5,7 @@ import cv2
5
  import gradio as gr
6
  from fastapi import FastAPI
7
  from fastapi.responses import HTMLResponse
8
- from fastrtc import Stream, WebRTCError, get_twilio_turn_credentials
9
  from gradio.utils import get_space
10
  from huggingface_hub import hf_hub_download
11
  from pydantic import BaseModel, Field
@@ -26,16 +26,10 @@ model = YOLOv10(model_file)
26
 
27
 
28
  def detection(image, conf_threshold=0.3):
29
- try:
30
- image = cv2.resize(image, (model.input_width, model.input_height))
31
- print("conf_threshold", conf_threshold)
32
- new_image = model.detect_objects(image, conf_threshold)
33
- return cv2.resize(new_image, (500, 500))
34
- except Exception as e:
35
- import traceback
36
-
37
- traceback.print_exc()
38
- raise WebRTCError(str(e))
39
 
40
 
41
  stream = Stream(
 
5
  import gradio as gr
6
  from fastapi import FastAPI
7
  from fastapi.responses import HTMLResponse
8
+ from fastrtc import Stream, get_twilio_turn_credentials
9
  from gradio.utils import get_space
10
  from huggingface_hub import hf_hub_download
11
  from pydantic import BaseModel, Field
 
26
 
27
 
28
  def detection(image, conf_threshold=0.3):
29
+ image = cv2.resize(image, (model.input_width, model.input_height))
30
+ print("conf_threshold", conf_threshold)
31
+ new_image = model.detect_objects(image, conf_threshold)
32
+ return cv2.resize(new_image, (500, 500))
 
 
 
 
 
 
33
 
34
 
35
  stream = Stream(