Spaces:
Runtime error
Runtime error
| from transformers import AutoFeatureExtractor, RegNetForImageClassification | |
| import torch | |
| import gradio as gr | |
| feature_extractor = AutoFeatureExtractor.from_pretrained("facebook/regnet-y-040") | |
| model = RegNetForImageClassification.from_pretrained("facebook/regnet-y-040") | |
| def inference(image): | |
| print("Type of image", type(image)) | |
| inputs = feature_extractor(image, return_tensors="pt") | |
| with torch.no_grad(): | |
| logits = model(**inputs).logits | |
| predicted_label = logits.argmax(-1).item() | |
| return model.config.id2label[predicted_label] | |
| title="RegNet-image-classification" | |
| description="This space uses RegNet Model with an image classification head on top (a linear layer on top of the pooled features). It predicts one of the 1000 ImageNet classes. Check [Docs](https://huggingface.co/docs/transformers/main/en/model_doc/regnet) for more details." | |
| examples=[['wolf.jpg'], ['ballon.jpg'], ['fountain.jpg']] | |
| iface = gr.Interface(inference, inputs=gr.inputs.Image(), outputs="text",title=title,description=description,examples=examples) | |
| iface.launch(enable_queue=True) |