changed imports
This commit is contained in:
+2
-1
@@ -12,7 +12,8 @@ COPY requirements.txt .
|
|||||||
|
|
||||||
RUN pip install --no-cache-dir -r requirements.txt
|
RUN pip install --no-cache-dir -r requirements.txt
|
||||||
|
|
||||||
COPY . .
|
COPY src .
|
||||||
|
COPY start_server.sh .
|
||||||
|
|
||||||
RUN chmod +x start_server.sh
|
RUN chmod +x start_server.sh
|
||||||
|
|
||||||
|
|||||||
@@ -1,21 +1,12 @@
|
|||||||
import json
|
|
||||||
import os
|
import os
|
||||||
import cv2
|
|
||||||
from matplotlib import pyplot as plt
|
|
||||||
import numpy as np
|
|
||||||
from torch import tensor
|
from torch import tensor
|
||||||
import torch
|
import torch
|
||||||
from torch.utils.data import DataLoader
|
from torch.utils.data import DataLoader
|
||||||
from torchvision import transforms
|
from torchvision.transforms import ToTensor
|
||||||
from torchvision.transforms import ToTensor, functional
|
|
||||||
import torchvision.transforms.functional as TF
|
|
||||||
from tqdm import tqdm
|
|
||||||
import torch.nn as nn
|
import torch.nn as nn
|
||||||
import torch.nn.functional as F
|
|
||||||
|
|
||||||
from .r_cnn import ObjectDetectionCNN, train, eval
|
from .r_cnn import ObjectDetectionCNN, train, eval
|
||||||
from .cocoDetectionDataset import CocoDetectionDataset
|
from .cocoDetectionDataset import CocoDetectionDataset
|
||||||
import random
|
|
||||||
|
|
||||||
SAVE_PATH = "./saved_models"
|
SAVE_PATH = "./saved_models"
|
||||||
PADDING = 20
|
PADDING = 20
|
||||||
|
|||||||
+4
-3
@@ -80,6 +80,7 @@ async def predict(file: UploadFile = File(...)):
|
|||||||
|
|
||||||
load_dotenv("../database/.env")
|
load_dotenv("../database/.env")
|
||||||
API_KEY = os.getenv("API_KEY")
|
API_KEY = os.getenv("API_KEY")
|
||||||
|
DATABASE = "../database/reviews.db"
|
||||||
|
|
||||||
def get_api_key(authorization: str = Header(None)):
|
def get_api_key(authorization: str = Header(None)):
|
||||||
if authorization != f"Bearer {API_KEY}":
|
if authorization != f"Bearer {API_KEY}":
|
||||||
@@ -98,7 +99,7 @@ sem_db = threading.Semaphore(1)
|
|||||||
def get_reviews(auth=Depends(get_api_key)):
|
def get_reviews(auth=Depends(get_api_key)):
|
||||||
with sem_db:
|
with sem_db:
|
||||||
conn = sqlite3.connect(
|
conn = sqlite3.connect(
|
||||||
"database/reviews.db",
|
DATABASE,
|
||||||
check_same_thread=False
|
check_same_thread=False
|
||||||
)
|
)
|
||||||
cur = conn.cursor()
|
cur = conn.cursor()
|
||||||
@@ -118,7 +119,7 @@ def get_reviews(auth=Depends(get_api_key)):
|
|||||||
def post_review(review: Review):
|
def post_review(review: Review):
|
||||||
with sem_db:
|
with sem_db:
|
||||||
conn = sqlite3.connect(
|
conn = sqlite3.connect(
|
||||||
"database/reviews.db",
|
DATABASE,
|
||||||
check_same_thread=False
|
check_same_thread=False
|
||||||
)
|
)
|
||||||
cur = conn.cursor()
|
cur = conn.cursor()
|
||||||
@@ -136,7 +137,7 @@ def post_review(review: Review):
|
|||||||
def delete_review(auth=Depends(get_api_key)):
|
def delete_review(auth=Depends(get_api_key)):
|
||||||
with sem_db:
|
with sem_db:
|
||||||
conn = sqlite3.connect(
|
conn = sqlite3.connect(
|
||||||
"database/reviews.db",
|
DATABASE,
|
||||||
check_same_thread=False
|
check_same_thread=False
|
||||||
)
|
)
|
||||||
cur = conn.cursor()
|
cur = conn.cursor()
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
from PIL import Image
|
|
||||||
import os
|
|
||||||
from matplotlib import pyplot as plt
|
from matplotlib import pyplot as plt
|
||||||
import torch
|
import torch
|
||||||
|
|
||||||
@@ -26,7 +24,6 @@ def visualizeData(dataset):
|
|||||||
for i in range(4):
|
for i in range(4):
|
||||||
img = images[i]
|
img = images[i]
|
||||||
|
|
||||||
# Convert tensor shape from [C,H,W] -> [H,W,C]
|
|
||||||
img = img.permute(1, 2, 0)
|
img = img.permute(1, 2, 0)
|
||||||
|
|
||||||
plt.figure(figsize=(3,3))
|
plt.figure(figsize=(3,3))
|
||||||
|
|||||||
+1
-1
@@ -1 +1 @@
|
|||||||
uvicorn server:app --host 0.0.0.0 --port 8000 --reload
|
uvicorn src/server:app --host 0.0.0.0 --port 8000 --reload
|
||||||
Reference in New Issue
Block a user