Spaces:
Runtime error
Runtime error
File size: 1,224 Bytes
6ed6d81 cb31bcc 6ed6d81 040f377 502d514 50e1bb0 6ed6d81 502d514 f8c560a cb31bcc f8c560a cb31bcc f8c560a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
from cgitb import enable
from ctypes.wintypes import HFONT
import os
import sys
import torch
import gradio as gr
import numpy as np
import torchvision.transforms as transforms
from torch.autograd import Variable
from huggingface_hub import hf_hub_download
from PIL import Image
import logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
MODEL_PATH = "models"
COLOUR_MODEL = "RGB"
MODEL_REPO = "NDugar/horse_to_zebra_cycle_GAN"
MODEL_FILE = "h2z-85epoch.pth"
model_hfhub = hf_hub_download(repo_id=MODEL_REPO, filename=MODEL_FILE)
enable_gpu = torch.cuda.is_available()
map_location = torch.device("cuda") if enable_gpu else "cpu"
from huggingface_hub import hf_hub_download
from fastai.learner import load_learner
model = torch.load("h2z-85epoch.pth",map_location=torch.device('cpu'))
def generate_img(img):
_,_,preds = learn.get_preds(dl=[b], with_decoded=True)
return preds
image = gr.inputs.Image(type="numpy")
op = gr.outputs.Image(type="numpy")
iface = gr.Interface(
generate_img,
image,
op,
title="CycleGAN-using UPIT",
description='CycleGAN model using Horse to Zebra using UPIT - https://github.com/tmabraham/UPIT'
)
iface.launch(cache_examples=False) |