hysts HF staff commited on
Commit
efb1d7d
1 Parent(s): 91b1804
Files changed (3) hide show
  1. README.md +1 -1
  2. app.py +7 -11
  3. requirements.txt +4 -4
README.md CHANGED
@@ -4,7 +4,7 @@ emoji: 😻
4
  colorFrom: green
5
  colorTo: gray
6
  sdk: gradio
7
- sdk_version: 3.19.1
8
  app_file: app.py
9
  pinned: false
10
  ---
 
4
  colorFrom: green
5
  colorTo: gray
6
  sdk: gradio
7
+ sdk_version: 3.36.1
8
  app_file: app.py
9
  pinned: false
10
  ---
app.py CHANGED
@@ -3,7 +3,6 @@
3
  from __future__ import annotations
4
 
5
  import functools
6
- import os
7
  import sys
8
 
9
  import gradio as gr
@@ -18,9 +17,7 @@ from data import read_img_path, tensor_to_img
18
  from model import UnetGenerator
19
 
20
  TITLE = 'Anime2Sketch'
21
- DESCRIPTION = 'This is an unofficial demo for https://github.com/Mukosame/Anime2Sketch.'
22
-
23
- HF_TOKEN = os.getenv('HF_TOKEN')
24
 
25
 
26
  def load_model(device: torch.device) -> nn.Module:
@@ -34,9 +31,8 @@ def load_model(device: torch.device) -> nn.Module:
34
  norm_layer=norm_layer,
35
  use_dropout=False)
36
 
37
- path = huggingface_hub.hf_hub_download('hysts/Anime2Sketch',
38
- 'netG.pth',
39
- use_auth_token=HF_TOKEN)
40
  ckpt = torch.load(path)
41
  for key in list(ckpt.keys()):
42
  if 'module.' in key:
@@ -65,15 +61,15 @@ def run(image_file: str,
65
  device = torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')
66
  model = load_model(device)
67
 
68
- func = functools.partial(run, model=model, device=device)
69
 
70
  examples = [['Anime2Sketch/test_samples/madoka.jpg']]
71
 
72
  gr.Interface(
73
- fn=func,
74
  inputs=gr.Image(label='Input', type='filepath'),
75
- outputs=gr.Image(label='Output', type='pil'),
76
  examples=examples,
77
  title=TITLE,
78
  description=DESCRIPTION,
79
- ).queue().launch(show_api=False)
 
3
  from __future__ import annotations
4
 
5
  import functools
 
6
  import sys
7
 
8
  import gradio as gr
 
17
  from model import UnetGenerator
18
 
19
  TITLE = 'Anime2Sketch'
20
+ DESCRIPTION = 'https://github.com/Mukosame/Anime2Sketch'
 
 
21
 
22
 
23
  def load_model(device: torch.device) -> nn.Module:
 
31
  norm_layer=norm_layer,
32
  use_dropout=False)
33
 
34
+ path = huggingface_hub.hf_hub_download('public-data/Anime2Sketch',
35
+ 'netG.pth')
 
36
  ckpt = torch.load(path)
37
  for key in list(ckpt.keys()):
38
  if 'module.' in key:
 
61
  device = torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')
62
  model = load_model(device)
63
 
64
+ fn = functools.partial(run, model=model, device=device)
65
 
66
  examples = [['Anime2Sketch/test_samples/madoka.jpg']]
67
 
68
  gr.Interface(
69
+ fn=fn,
70
  inputs=gr.Image(label='Input', type='filepath'),
71
+ outputs=gr.Image(label='Output'),
72
  examples=examples,
73
  title=TITLE,
74
  description=DESCRIPTION,
75
+ ).queue().launch()
requirements.txt CHANGED
@@ -1,4 +1,4 @@
1
- numpy==1.22.3
2
- Pillow==9.1.0
3
- torch==1.11.0
4
- torchvision==0.12.0
 
1
+ numpy==1.23.5
2
+ Pillow==10.0.0
3
+ torch==2.0.1
4
+ torchvision==0.15.2