root
commited on
Commit
•
376eaac
0
Parent(s):
first commit
Browse files- Makefile +27 -0
- app.py +36 -0
- requirements.txt +2 -0
Makefile
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
install:
|
2 |
+
pip install --upgrade pip &&\
|
3 |
+
pip install -r requirements.txt
|
4 |
+
|
5 |
+
test:
|
6 |
+
python -m pytest -vvv --cov=hello --cov=greeting \
|
7 |
+
--cov=smath --cov=web tests
|
8 |
+
python -m pytest --nbval notebook.ipynb #tests our jupyter notebook
|
9 |
+
#python -m pytest -v tests/test_web.py #if you just want to test web
|
10 |
+
|
11 |
+
debug:
|
12 |
+
python -m pytest -vv --pdb #Debugger is invoked
|
13 |
+
|
14 |
+
one-test:
|
15 |
+
python -m pytest -vv tests/test_greeting.py::test_my_name4
|
16 |
+
|
17 |
+
debugthree:
|
18 |
+
#not working the way I expect
|
19 |
+
python -m pytest -vv --pdb --maxfail=4 # drop to PDB for first three failures
|
20 |
+
|
21 |
+
format:
|
22 |
+
black *.py
|
23 |
+
|
24 |
+
lint:
|
25 |
+
pylint --disable=R,C *.py
|
26 |
+
|
27 |
+
all: install lint test format
|
app.py
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from PIL import Image
|
2 |
+
import torch
|
3 |
+
import gradio
|
4 |
+
|
5 |
+
Instructuction = "Select a Unique Portrait Image of yourself"
|
6 |
+
title="I am something of a Painter, Anime-Edition (AnimeGAN-V2)"
|
7 |
+
description = "Drag/Drop or Upload a cute portrait Image of yourself or anyone you find interesting 😉, then observe how this Generative model\
|
8 |
+
is able to Generate a cute Anime-Cartoon version of your Image."
|
9 |
+
article = """
|
10 |
+
- Select an image from the examples provided as demo image,
|
11 |
+
- Click submit to Generate Image,
|
12 |
+
- Tips: Quality Images with Great brightness/without pre-existing filters work better (Image Noise).
|
13 |
+
- Privacy: No user data is collected or saved,
|
14 |
+
- Credits to akhaliq/AnimeGANv2 for original AnimeGanV2"""
|
15 |
+
|
16 |
+
model = torch.hub.load(
|
17 |
+
"AK391/animegan2-pytorch:main",
|
18 |
+
"generator",
|
19 |
+
pretrained=True,
|
20 |
+
device="cuda",
|
21 |
+
progress=False
|
22 |
+
)
|
23 |
+
face2paint = torch.hub.load(
|
24 |
+
'AK391/animegan2-pytorch:main', 'face2paint',
|
25 |
+
size=512, device="cuda",side_by_side=False
|
26 |
+
)
|
27 |
+
|
28 |
+
def inference(img):
|
29 |
+
return face2paint(model, img)
|
30 |
+
|
31 |
+
gradio.Interface(inference,
|
32 |
+
inputs=gradio.Image(type='pil'),
|
33 |
+
outputs=gradio.Image(type='pil'),
|
34 |
+
Instructuction=Instructuction, title=title, description=description, article=article,
|
35 |
+
examples=['/content/Upload Xty.png',
|
36 |
+
'/content/Upload Tg.png']).launch()
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
gradio
|
2 |
+
tourch
|