Update app.py
Browse files
app.py
CHANGED
|
@@ -10,11 +10,12 @@ import albumentations as A
|
|
| 10 |
from albumentations.pytorch import ToTensorV2
|
| 11 |
import config
|
| 12 |
|
| 13 |
-
|
| 14 |
|
| 15 |
from model import YOLOv3
|
| 16 |
import config
|
| 17 |
from torchvision import transforms
|
|
|
|
| 18 |
|
| 19 |
scaled_anchors = (
|
| 20 |
torch.tensor(config.ANCHORS)
|
|
@@ -22,7 +23,9 @@ scaled_anchors = (
|
|
| 22 |
).to('cpu')
|
| 23 |
|
| 24 |
model = YOLOv3(num_classes=config.NUM_CLASSES)
|
| 25 |
-
|
|
|
|
|
|
|
| 26 |
|
| 27 |
test_transforms_exp = A.Compose(
|
| 28 |
[
|
|
@@ -42,15 +45,16 @@ def inference(input_img,show_gradcam="yes", transparency = 0.5, target_layer_num
|
|
| 42 |
input_img = transform(input_img)
|
| 43 |
input_img = input_img
|
| 44 |
input_img = input_img.unsqueeze(0)
|
| 45 |
-
out_fig = plot_single_image(model, input_img, 0.6, 0.5,scaled_anchors)
|
| 46 |
return out_fig
|
| 47 |
|
| 48 |
title = "TSAI S13 Assignment: YOLO V3 trained on PASCAL VOC Dataset"
|
| 49 |
-
description = "A simple Gradio interface
|
| 50 |
-
examples = [["
|
|
|
|
|
|
|
|
|
|
| 51 |
]
|
| 52 |
-
|
| 53 |
-
#gr.Radio(["yes", "no"], label="Show Gradcam"),gr.Slider(0, 1, value = 0.5, label="If yes, Opacity of GradCAM"), gr.Slider(-2, -1, value = -2, step=1, label="If yes, Which Layer?")
|
| 54 |
demo = gr.Interface(
|
| 55 |
inference,
|
| 56 |
inputs = [gr.Image(shape=(416, 416), label="Input Image")],
|
|
|
|
| 10 |
from albumentations.pytorch import ToTensorV2
|
| 11 |
import config
|
| 12 |
|
| 13 |
+
import utils
|
| 14 |
|
| 15 |
from model import YOLOv3
|
| 16 |
import config
|
| 17 |
from torchvision import transforms
|
| 18 |
+
import torch.optim as optim
|
| 19 |
|
| 20 |
scaled_anchors = (
|
| 21 |
torch.tensor(config.ANCHORS)
|
|
|
|
| 23 |
).to('cpu')
|
| 24 |
|
| 25 |
model = YOLOv3(num_classes=config.NUM_CLASSES)
|
| 26 |
+
optimizer = optim.Adam(model.parameters(), lr=config.LEARNING_RATE, weight_decay=config.WEIGHT_DECAY)
|
| 27 |
+
|
| 28 |
+
utils.load_checkpoint("checkpoint.pth[1].tar", model, optimizer, config.LEARNING_RATE)
|
| 29 |
|
| 30 |
test_transforms_exp = A.Compose(
|
| 31 |
[
|
|
|
|
| 45 |
input_img = transform(input_img)
|
| 46 |
input_img = input_img
|
| 47 |
input_img = input_img.unsqueeze(0)
|
| 48 |
+
out_fig = utils.plot_single_image(model, input_img, 0.6, 0.5,scaled_anchors)
|
| 49 |
return out_fig
|
| 50 |
|
| 51 |
title = "TSAI S13 Assignment: YOLO V3 trained on PASCAL VOC Dataset"
|
| 52 |
+
description = "A simple Gradio interface for object detection using YOLO V3 algorithm. Bounding boxes are shown around objects"
|
| 53 |
+
examples = [["000002.jpg","yes", 0.5, -1],
|
| 54 |
+
["000004.jpg","yes", 0.5, -1],
|
| 55 |
+
["000006.jpg","yes", 0.5, -1],
|
| 56 |
+
["000058.jpg","yes", 0.5, -1]
|
| 57 |
]
|
|
|
|
|
|
|
| 58 |
demo = gr.Interface(
|
| 59 |
inference,
|
| 60 |
inputs = [gr.Image(shape=(416, 416), label="Input Image")],
|