I want to deploy a Huggingface tranformer object detection model with Gradio. I have followed exactly the Gradio documentation for transformer models, but I keep getting the error message below every time I try to launch the app:
ValueError Traceback (most recent call last)
<ipython-input-21-ae95d9ecbd73> in <module>()
----> 1 gr.Interface.from_pipeline(obj_detect).launch(share = True)
1 frames
/usr/local/lib/python3.7/dist-packages/gradio/external.py in load_from_pipeline(pipeline)
575 }
576 else:
--> 577 raise ValueError("Unsupported pipeline type: {}".format(type(pipeline)))
578
579 # define the function that will be called by the Interface
ValueError: Unsupported pipeline type: <class 'transformers.pipelines.object_detection.ObjectDetectionPipeline'>
This is my code:
Import timm
Import gradio as gr
from transformers import pipeline
obj_detect = pipeline("object-detection")
gr.Interface.from_pipeline(obj_detect).launch(share = True)
And when I actually define a function, and launch the app, the app launches but returns an error when I try to make a prediction. Here is my function wrapper:
def Object_detector(image):
obj_detect = pipeline("object-detection")
detect = obj_detect(image)
return detect
app = gr.Interface(Object_detector,inputs = "image",outputs = "label")
app.launch(share = True)
This is strange to me, because I have followed the documentation exactly, yet I am getting an error. Please, your advice will be very much appreciated.