Update main.py
Browse files
main.py
CHANGED
|
@@ -1,11 +1,11 @@
|
|
| 1 |
-
import gradio as
|
| 2 |
import torch
|
| 3 |
-
from torchvision import
|
| 4 |
|
| 5 |
# -- get torch and cuda version
|
| 6 |
TORCH_VERSION = ".".join(torch.__version__.split(".")[:2])
|
| 7 |
CUDA_VERSION = torch.__version__.split("+")[-1]
|
| 8 |
-
|
| 9 |
# -- install pre-build detectron2
|
| 10 |
!pip install detectron2 -f https://dl.fbaipublicfiles.com/detectron2/wheels/{CUDA_VERSION}/{TORCH_VERSION}/index.html
|
| 11 |
|
|
@@ -36,7 +36,7 @@ outputs = predictor(im)
|
|
| 36 |
|
| 37 |
print(outputs["instances"].pred_classes)
|
| 38 |
print(outputs["instances"].pred_boxes)
|
| 39 |
-
|
| 40 |
# -- load Mask R-CNN model for segmentation
|
| 41 |
DesignModernityModel = torch.load("DesignModernityModel.pt")
|
| 42 |
|
|
@@ -45,12 +45,9 @@ DesignModernityModel = torch.load("DesignModernityModel.pt")
|
|
| 45 |
|
| 46 |
DesignModernityModel.eval() # set state of the model to inference
|
| 47 |
|
| 48 |
-
LABELS = ['
|
| 49 |
|
| 50 |
-
carTransforms = transforms.Compose([
|
| 51 |
-
transforms.RandomResizedCrop(224),
|
| 52 |
-
...
|
| 53 |
-
])
|
| 54 |
|
| 55 |
def classifyCar(im):
|
| 56 |
im = Image.fromarray(im.astype('uint8'), 'RGB')
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
import torch
|
| 3 |
+
from torchvision import models, transforms
|
| 4 |
|
| 5 |
# -- get torch and cuda version
|
| 6 |
TORCH_VERSION = ".".join(torch.__version__.split(".")[:2])
|
| 7 |
CUDA_VERSION = torch.__version__.split("+")[-1]
|
| 8 |
+
'''
|
| 9 |
# -- install pre-build detectron2
|
| 10 |
!pip install detectron2 -f https://dl.fbaipublicfiles.com/detectron2/wheels/{CUDA_VERSION}/{TORCH_VERSION}/index.html
|
| 11 |
|
|
|
|
| 36 |
|
| 37 |
print(outputs["instances"].pred_classes)
|
| 38 |
print(outputs["instances"].pred_boxes)
|
| 39 |
+
'''
|
| 40 |
# -- load Mask R-CNN model for segmentation
|
| 41 |
DesignModernityModel = torch.load("DesignModernityModel.pt")
|
| 42 |
|
|
|
|
| 45 |
|
| 46 |
DesignModernityModel.eval() # set state of the model to inference
|
| 47 |
|
| 48 |
+
LABELS = ['2000-2004', '2006-2008', '2009-2011', '2012-2015', '2016-2018']
|
| 49 |
|
| 50 |
+
carTransforms = transforms.Compose([transforms.Resize(224)])
|
|
|
|
|
|
|
|
|
|
| 51 |
|
| 52 |
def classifyCar(im):
|
| 53 |
im = Image.fromarray(im.astype('uint8'), 'RGB')
|