server ready for deplyment
This commit is contained in:
Binary file not shown.
Binary file not shown.
+3
-3
@@ -11,7 +11,7 @@ import torch.nn.functional as F
|
|||||||
|
|
||||||
from bird_cnn import Bird_CNN
|
from bird_cnn import Bird_CNN
|
||||||
|
|
||||||
SAVE_PATH = "./saved_models"
|
BUILD_PATH = "./build_models"
|
||||||
#IMAGE_SIZE = (1141, 850)
|
#IMAGE_SIZE = (1141, 850)
|
||||||
IMAGE_SIZE = (300, 300)
|
IMAGE_SIZE = (300, 300)
|
||||||
|
|
||||||
@@ -36,8 +36,8 @@ transform = transforms.Compose([
|
|||||||
|
|
||||||
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
||||||
|
|
||||||
model = Bird_CNN(c_in=3, c_hidden=15, c_out=7, kernel_size=3, img_width=IMAGE_SIZE[0], img_height=IMAGE_SIZE[1])
|
model = Bird_CNN(c_in=3, c_hidden=15, c_out=7)
|
||||||
full_path = os.path.join(SAVE_PATH, "bird_cnn", "bird_cnn")
|
full_path = os.path.join(BUILD_PATH, "bird_cnn")
|
||||||
model.load_state_dict(torch.load(full_path, weights_only=False))
|
model.load_state_dict(torch.load(full_path, weights_only=False))
|
||||||
model.to(device)
|
model.to(device)
|
||||||
model.eval()
|
model.eval()
|
||||||
|
|||||||
@@ -2,6 +2,9 @@ import { useState } from 'react'
|
|||||||
import './Bird_CNN.css'
|
import './Bird_CNN.css'
|
||||||
|
|
||||||
function Bird_CNN() {
|
function Bird_CNN() {
|
||||||
|
const apiUrl = process.env.NODE_ENV === "development"
|
||||||
|
? "http://127.0.0.1:8000"
|
||||||
|
: "https://api.myapp.com";
|
||||||
|
|
||||||
const [file, setFile] = useState(null);
|
const [file, setFile] = useState(null);
|
||||||
const [birdClass, setBirdClass] = useState(null);
|
const [birdClass, setBirdClass] = useState(null);
|
||||||
@@ -19,7 +22,7 @@ function Bird_CNN() {
|
|||||||
formData.append("file", file);
|
formData.append("file", file);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch("http://127.0.0.1:8000/predict", {
|
const response = await fetch(`${apiUrl}/predict`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: formData,
|
body: formData,
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user