This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(readr) | |
confirmed <- read_csv("https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_confirmed_global.csv") | |
head(confirmed) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import time | |
import copy | |
import os | |
import torch | |
import torch.optim as optim | |
import torch.nn as nn | |
import torchvision | |
import matplotlib.pyplot as plt | |
from torch.optim import lr_scheduler |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Load the model (Download only at first time loading the model) | |
model_resnet = models.resnet18(pretrained=True) | |
model_vgg16 = models.vgg16(pretrained=True) | |
model_alexnet = models.alexnet(pretrained=True) | |
# Define the function to train the model | |
def train_model(model, criterion, optimizer, scheduler, num_epochs=25): | |
since = time.time() | |
best_model_wts = copy.deepcopy(model.state_dict()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Show the images and the ground truth | |
dataiter = iter(dataloaders['test']) | |
images, labels = dataiter.next() | |
imshow(torchvision.utils.make_grid(images)) | |
print('GroundTruth: ', ', '.join('%5s' % class_names[x] for x in labels)) | |
# Predict the model | |
images = images.to(device) | |
labels = images.to(device) | |
output = model_resnet(images) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Save The Model | |
PATH = './fix_alexnet_net.pth' | |
torch.save(model_alexnet.state_dict(), PATH) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Declare the network | |
net = Net() | |
# Set the parameters | |
net.load_state_dict(torch.load(PATH)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import io | |
import string | |
import torch | |
import torch.nn as nn | |
import torchvision.transforms as transforms | |
from torchvision import models | |
from flask import Flask, jsonify, request, render_template | |
from PIL import Image | |
app = Flask(__name__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE HTML> | |
<html> | |
<head> | |
<!-- Required meta tags --> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | |
<!-- Bootstrap CSS --> | |
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% extends "layout.html" %} | |
{% block content %} | |
<form class="form-signin" method=post enctype=multipart/form-data> | |
<h1 class="h2 mb-3 font-weight-normal">Apple Leaf Disease Classifier</h1> | |
<h2 class="h4 mb-3 font-weight-normal">Please Upload The Image</h2> | |
<input type="file" name="file" class="form-control-file" id="inputfile" onchange="preview_image(event)"> | |
<br /> | |
<img id="output-image" class="rounded mx-auto d-block"/> | |
<button class="btn btn-lg btn-primary btn-block" type="submit">Upload</button> | |
<p class="mt-5 mb-3 text-muted">Powered by PyTorch, Flask, and Bootstrap.</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% extends "layout.html" %} | |
{% block content %} | |
<form class="form-signin" method=post enctype=multipart/form-data> | |
{% if name == "healthy"%} | |
<h1 class="h1 mb-3 font-weight-normal"> Your plant is healthy! </h1> | |
{% else %} | |
<h1 class="h1 mb-3 font-weight-normal"> Your leaf got a {{ name }} disease!</h5> | |
<h3 class="h5 mb-3 font-weight-normal"> {{ description }} </p> | |
{% endif %} | |
<p class="mt-5 mb-3 text-muted">Powered by PyTorch, Flask, and Bootstrap.</p> |
OlderNewer