Spaces:
Sleeping
Sleeping
To support zero zero-gpu
Browse files4 unmodified lines56789101112133 unmodified lines1718192021222324254 unmodified linesfrom timm.data import create_transform# Prepare the model.import modelsmodel = models.mambaout_femto(pretrained=True) # can change different model namemodel.eval()# Prepare the transform.3 unmodified linesresponse = requests.get("https://git.io/JJkYN")labels = response.text.split("\n")def predict(inp):inp = transform(inp).unsqueeze(0)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)}4 unmodified lines567891011121314153 unmodified lines1920212223242526274 unmodified linesfrom timm.data import create_transformdevice = "cuda"# Prepare the model.import modelsmodel = 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).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