forked from monniert/unicorn
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpredict.py
More file actions
33 lines (23 loc) · 822 Bytes
/
predict.py
File metadata and controls
33 lines (23 loc) · 822 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# Prediction interface for Cog ⚙️
# https://github.com/replicate/cog/blob/main/docs/python.md
from cog import BasePredictor, BaseModel, File, Input, Path
from reconstruct_cog import reconstruct
from typing import Any
import torch
print('cuda status is',torch.cuda.is_available())
# import unicorn here
class Output(BaseModel):
file: File
class Predictor(BasePredictor):
def setup(self):
"""Load the model into memory to make running multiple predictions efficient"""
def predict(
self,
model: str,
input: Path = Input(description="Image to classify")
) -> Any:
"""Run a single prediction on the model"""
try:
return Output(file=reconstruct(model, input))
except Exception as e:
return f"Error: {e}"