Upload 5 files
Browse files
Makefile
CHANGED
@@ -1,27 +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
|
|
|
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
CHANGED
@@ -1,7 +1,8 @@
|
|
1 |
-
from PIL import Image
|
2 |
import torch
|
3 |
import torchvision
|
4 |
import gradio
|
|
|
5 |
|
6 |
Instructuction = "Select a Unique Portrait Image of yourself"
|
7 |
title="I am something of a Painter, Anime-Edition (AnimeGAN-V2)"
|
@@ -27,12 +28,28 @@ face2paint = torch.hub.load(
|
|
27 |
side_by_side=False
|
28 |
)
|
29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
def inference(img):
|
31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
|
33 |
gradio.Interface(inference,
|
34 |
-
inputs=gradio.Image(type='
|
35 |
-
outputs=gradio.Image(type='
|
36 |
-
Instructuction=Instructuction, title=title, description=description, article=article
|
37 |
-
examples=['Upload Xty.png',
|
38 |
-
'Upload Tg.png']).launch()
|
|
|
1 |
+
from PIL import Image, ImageDraw, ImageFont, ImageEnhance
|
2 |
import torch
|
3 |
import torchvision
|
4 |
import gradio
|
5 |
+
import numpy as np
|
6 |
|
7 |
Instructuction = "Select a Unique Portrait Image of yourself"
|
8 |
title="I am something of a Painter, Anime-Edition (AnimeGAN-V2)"
|
|
|
28 |
side_by_side=False
|
29 |
)
|
30 |
|
31 |
+
def enhance_logo_brightness(logo_image, factor):
|
32 |
+
enhancer = ImageEnhance.Brightness(logo_image)
|
33 |
+
return enhancer.enhance(factor)
|
34 |
+
|
35 |
+
def add_logo(image):
|
36 |
+
logo_path = "./logo.jpg" # 로고 파일 경로
|
37 |
+
logo_size = (100, 30) # 로고 크기
|
38 |
+
logo = Image.open(logo_path).convert("RGBA")
|
39 |
+
logo = logo.resize(logo_size, resample=Image.BICUBIC)
|
40 |
+
logo = enhance_logo_brightness(logo, 1.5) # 로고 이미지의 밝기를 조절합니다.
|
41 |
+
return logo
|
42 |
+
|
43 |
def inference(img):
|
44 |
+
img_pil = Image.fromarray(img.astype('uint8'), 'RGB') # 이미지를 PIL 이미지 객체로 변환
|
45 |
+
output_image_pil = face2paint(model, img_pil.resize((512, 512))) # 이미지 변환
|
46 |
+
output_image_pil = output_image_pil.convert('RGB') # RGBA -> RGB 변환
|
47 |
+
logo = add_logo(output_image_pil) # 로고 이미지 가져오기
|
48 |
+
output_image_pil.paste(logo, (512 - logo.size[0], 512 - logo.size[1]), logo) # 로고 이미지를 생성된 이미지에 붙이기
|
49 |
+
output_image = np.array(output_image_pil) # PIL 이미지 객체를 numpy 배열로 변환
|
50 |
+
return output_image
|
51 |
|
52 |
gradio.Interface(inference,
|
53 |
+
inputs=gradio.Image(type='numpy'),
|
54 |
+
outputs=gradio.Image(type='numpy'),
|
55 |
+
Instructuction=Instructuction, title=title, description=description, article=article).launch()
|
|
|
|
logo.jpg
CHANGED
requirements.txt
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
-
gradio
|
2 |
-
torch
|
3 |
-
torchvision
|
|
|
1 |
+
gradio
|
2 |
+
torch
|
3 |
+
torchvision
|