Update app.py
Browse files
app.py
CHANGED
@@ -364,6 +364,7 @@ if uploaded_file is not None:
|
|
364 |
image_1 = infer(model, image, 0.5, 0.5, scaled_anchors)
|
365 |
|
366 |
#task 2
|
|
|
367 |
file_path = f"2007_task2_{base}_{new}_mAP_{base}_{new}.pth.tar"
|
368 |
model = YOLOv3(num_classes=all).to(device)
|
369 |
checkpoint = torch.load(file_path, map_location=device)
|
@@ -372,6 +373,7 @@ if uploaded_file is not None:
|
|
372 |
image_2 = infer(model, image, 0.5, 0.5, scaled_anchors)
|
373 |
|
374 |
#ft
|
|
|
375 |
file_path = f"2007_finetune_{base}_{new}_mAP_{base}_{new}.pth.tar"
|
376 |
checkpoint = torch.load(file_path, map_location=device)
|
377 |
model.load_state_dict(checkpoint["state_dict"])
|
@@ -383,7 +385,9 @@ if uploaded_file is not None:
|
|
383 |
# note = Image.open("note.png")
|
384 |
# st.image(note, width=150)
|
385 |
|
386 |
-
|
|
|
|
|
387 |
col1, col2, col3, col4 = st.columns(4)
|
388 |
with col1:
|
389 |
st.image(image, caption="Ảnh đầu vào", use_column_width=True)
|
|
|
364 |
image_1 = infer(model, image, 0.5, 0.5, scaled_anchors)
|
365 |
|
366 |
#task 2
|
367 |
+
image = Image.open(uploaded_file)
|
368 |
file_path = f"2007_task2_{base}_{new}_mAP_{base}_{new}.pth.tar"
|
369 |
model = YOLOv3(num_classes=all).to(device)
|
370 |
checkpoint = torch.load(file_path, map_location=device)
|
|
|
373 |
image_2 = infer(model, image, 0.5, 0.5, scaled_anchors)
|
374 |
|
375 |
#ft
|
376 |
+
image = Image.open(uploaded_file)
|
377 |
file_path = f"2007_finetune_{base}_{new}_mAP_{base}_{new}.pth.tar"
|
378 |
checkpoint = torch.load(file_path, map_location=device)
|
379 |
model.load_state_dict(checkpoint["state_dict"])
|
|
|
385 |
# note = Image.open("note.png")
|
386 |
# st.image(note, width=150)
|
387 |
|
388 |
+
image_1 = cv2.cvtColor(image_1, cv2.COLOR_BGR2RGB)
|
389 |
+
image_2 = cv2.cvtColor(image_2, cv2.COLOR_BGR2RGB)
|
390 |
+
image_3 = cv2.cvtColor(image_3, cv2.COLOR_BGR2RGB)
|
391 |
col1, col2, col3, col4 = st.columns(4)
|
392 |
with col1:
|
393 |
st.image(image, caption="Ảnh đầu vào", use_column_width=True)
|