Spaces:
Sleeping
Sleeping
To support zero zero-gpu
Browse files4 unmodified lines56789101110121314153 unmodified lines19202122232122242526274 unmodified linesfrom timm.data import create_transform
device = "cuda"
# Prepare the model.import modelsmodel = models.mambaout_femto(pretrained=True) # can change different model namemodel = models.mambaout_femto(pretrained=True).to(device=device) # can change different model namemodel.eval()
# Prepare the transform.3 unmodified linesresponse = requests.get("https://git.io/JJkYN")labels = response.text.split("\n")
+@spaces.GPUdef predict(inp): inp = transform(inp).unsqueeze(0)
inp = transform(inp).unsqueeze(0).to(device=device) with torch.no_grad(): prediction = torch.nn.functional.softmax(model(inp)[0], dim=0) confidences = {labels[i]: float(prediction[i]) for i in range(1000)}app.py+5-3