This file contains hidden or 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 pandas as pd | |
| import random | |
| import datetime | |
| def random_dt_bw(start_date,end_date): | |
| days_between = (end_date - start_date).days | |
| random_num_days = random.randrange(days_between) | |
| random_dt = start_date + datetime.timedelta(days=random_num_days) | |
| return random_dt |
This file contains hidden or 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 pandas as pd | |
| import random | |
| import datetime | |
| def random_dt_bw(start_date,end_date): | |
| days_between = (end_date - start_date).days | |
| random_num_days = random.randrange(days_between) | |
| random_dt = start_date + datetime.timedelta(days=random_num_days) | |
| return random_dt |
This file contains hidden or 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
| # Lists to keep track of progress/Losses | |
| img_list = [] | |
| G_losses = [] | |
| D_losses = [] | |
| iters = 0 | |
| # Number of training epochs | |
| num_epochs = 50 | |
| # Batch size during training | |
| batch_size = 128 |
This file contains hidden or 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
| # Initialize BCELoss function | |
| criterion = nn.BCELoss() | |
| # Create batch of latent vectors that we will use to visualize | |
| # the progression of the generator | |
| fixed_noise = torch.randn(64, nz, 1, 1, device=device) | |
| # Establish convention for real and fake labels during training | |
| real_label = 1. | |
| fake_label = 0. |
This file contains hidden or 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
| # Number of channels in the training images. For color images this is 3 | |
| nc = 3 | |
| # Size of feature maps in discriminator | |
| ndf = 64 | |
| class Discriminator(nn.Module): | |
| def __init__(self, ngpu): | |
| super(Discriminator, self).__init__() | |
| self.ngpu = ngpu | |
| self.main = nn.Sequential( |
This file contains hidden or 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
| # Size of feature maps in generator | |
| ngf = 64 | |
| # Number of channels in the training images. For color images this is 3 | |
| nc = 3 | |
| # Size of z latent vector (i.e. size of generator input noise) | |
| nz = 100 | |
| class Generator(nn.Module): | |
| def __init__(self, ngpu): | |
| super(Generator, self).__init__() |
This file contains hidden or 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
| # Root directory for dataset | |
| dataroot = "anime_images/" | |
| # Number of workers for dataloader | |
| workers = 2 | |
| # Batch size during training | |
| batch_size = 128 | |
| # Spatial size of training images. All images will be resized to this size using a transformer. | |
| image_size = 64 | |
| # Number of channels in the training images. For color images this is 3 | |
| nc = 3 |
This file contains hidden or 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 streamlit as st | |
| import base64 | |
| import io | |
| import requests,json | |
| from PIL import Image | |
| import cv2 | |
| import numpy as np | |
| import matplotlib.pyplot as plt | |
| import requests | |
| import random |
This file contains hidden or 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
| from PIL import Image | |
| import numpy as np | |
| import cv2 | |
| import matplotlib.pyplot as plt | |
| def PILImage_to_cv2(img): | |
| return np.asarray(img) | |
| def drawboundingbox(img, boxes,pred_cls, rect_th=2, text_size=1, text_th=2): | |
| img = PILImage_to_cv2(img) |
This file contains hidden or 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
| from fastapi import FastAPI | |
| from pydantic import BaseModel | |
| import torchvision | |
| from torchvision import transforms | |
| import torch | |
| from torchvision.models.detection.faster_rcnn import FastRCNNPredictor | |
| from PIL import Image | |
| import numpy as np | |
| import cv2 | |
| import io, json |