Spaces:
Runtime error
Runtime error
Martin Tomov commited on
rm spaces
Browse files1234567891011121314151617181920212223242526272829303132333435363738394041427 unmodified lines505152535455565758596061import spaces # on top as CUDA needs to be initialized after `spaces`import ostry:import detectron2except ImportError:import osos.system('pip install git+https://github.com/facebookresearch/detectron2.git')try:from segment_anything import build_sam, SamPredictorexcept ImportError:import osos.system('pip install git+https://github.com/facebookresearch/segment-anything.git')from segment_anything import build_sam, SamPredictortry:import grounded_dinoexcept ImportError:import osos.system('pip install transformers')os.system('pip install git+https://github.com/IDEA-Research/GroundingDINO.git')import gradio as grimport jsonimport numpy as npfrom sam_utils import grounded_segmentation, create_yellow_background_with_insectsfrom yolo_utils import yolo_processimagefrom detectron_utils import detectron_process_imagefrom gsl_utils import gsl_process_image@spaces.GPUdef process_image(image, include_json):detectron_result = detectron_process_image(image)yolo_result = yolo_processimage(image)insectsam_result = create_yellow_background_with_insects(image)gsl_result = gsl_process_image(image)return insectsam_result, yolo_result, detectron_result, gsl_resultexamples = [["imgs/demo.jpg"],7 unmodified linesgr.Interface(fn=process_image,inputs=[gr.Image(type="pil")],outputs=[gr.Image(label='InsectSAM', type="numpy"),gr.Image(label='Yolov8', type="numpy"),gr.Image(label='Detectron', type="numpy"),gr.Image(label='GSL', type="numpy")],title="Insect Model Zoo ππ¬",examples=examples).launch()1234567891011121314151617181920217 unmodified lines293031323334353637try:import detectron2except:import osos.system('pip install git+https://github.com/facebookresearch/detectron2.git')import gradio as grimport jsonimport numpy as npfrom sam_utils import grounded_segmentation, create_yellow_background_with_insectsfrom yolo_utils import yolo_processimagefrom detectron_utils import detectron_process_imagedef process_image(image, include_json):detectron_result=detectron_process_image(image)yolo_result = yolo_processimage(image)insectsam_result = create_yellow_background_with_insects(image)return insectsam_result, yolo_result, detectron_resultexamples = [["imgs/demo.jpg"],7 unmodified linesgr.Interface(fn=process_image,inputs=[gr.Image(type="pil")],outputs=[gr.Image(label='InsectSAM', type="numpy"),gr.Image(label='Yolov8', type="numpy"),gr.Image(label='Detectron', type="numpy")],title="Insect Model Zoo ππ¬",examples=examples).launch()
app.py+8-32