Luisgust commited on
Commit
a1be8f1
·
verified ·
1 Parent(s): 5f0bb85

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -24
app.py CHANGED
@@ -3,10 +3,8 @@ import cv2
3
  import gradio as gr
4
  import AnimeGANv3_src
5
 
6
-
7
  os.makedirs('output', exist_ok=True)
8
 
9
-
10
  def inference(img_path, Style, if_face=None):
11
  print(img_path, Style, if_face)
12
  try:
@@ -32,7 +30,7 @@ def inference(img_path, Style, if_face=None):
32
  f = "U"
33
 
34
  try:
35
- det_face = True if if_face=="Yes" else False
36
  output = AnimeGANv3_src.Convert(img, f, det_face)
37
  save_path = f"output/out.{img_path.rsplit('.')[-1]}"
38
  cv2.imwrite(save_path, output[:, :, ::-1])
@@ -43,16 +41,14 @@ def inference(img_path, Style, if_face=None):
43
  print('global exception', error)
44
  return None, None
45
 
46
-
47
  title = "AnimeGANv3: To produce your own animation."
48
  description = r"""Official online demo for <a href='https://github.com/TachibanaYoshino/AnimeGANv3' target='_blank'><b>AnimeGANv3</b></a>. If you like what I'm doing you can tip me on <a href='https://www.patreon.com/Asher_Chan' target='_blank'><b>**patreon**</b></a>.<br>
49
  It can be used to turn your photos or videos into anime.<br>
50
  To use it, simply upload your image. It can convert landscape photos to Hayao Miyazaki or Makoto Shinkai style anime, as well as 4 style conversions about human faces.<br>
51
  If AnimeGANv3 is helpful, please help to ⭐ the <a href='https://github.com/TachibanaYoshino/AnimeGANv3' target='_blank'>Github Repo</a> and recommend it to your friends. 😊
52
-
53
  """
54
- article = r"""
55
 
 
56
  [![GitHub Stars](https://img.shields.io/github/stars/TachibanaYoshino/AnimeGANv3?style=social)](https://github.com/TachibanaYoshino/AnimeGANv3)
57
 
58
  ### 🗻 Demo
@@ -81,31 +77,37 @@ If you have any question, please open an issue on GitHub Repo.
81
 
82
  <center><img src='https://visitor-badge.glitch.me/badge?page_id=AnimeGANv3_online' alt='visitor badge'></center>
83
  """
84
- gr.Interface(
85
- inference, [
 
 
86
  gr.Image(type="filepath", label="Input"),
87
- gr.Dropdown([
88
- 'AnimeGANv3_Hayao',
89
- 'AnimeGANv3_Shinkai',
90
- 'AnimeGANv3_Arcane',
91
- 'AnimeGANv3_USA',
92
- 'AnimeGANv3_Trump v1.0',
93
- 'AnimeGANv3_Disney v1.0',
94
- 'AnimeGANv3_PortraitSketch',
95
- 'AnimeGANv3_JP_face v1.0',
96
- 'AnimeGANv3_Kpop v2.0',
97
- ],
 
98
  type="value",
99
  value='AnimeGANv3_Hayao',
100
- label='AnimeGANv3 Style'),
 
101
  gr.Radio(['Yes', 'No'], type="value", value='No', label='Extract face'),
102
- ], [
 
103
  gr.Image(type="numpy", label="Output (The whole image)"),
104
  gr.File(label="Download the output image")
105
  ],
106
  title=title,
107
  description=description,
108
  article=article,
109
- allow_flagging="never",
110
-
111
- .launch())
 
 
3
  import gradio as gr
4
  import AnimeGANv3_src
5
 
 
6
  os.makedirs('output', exist_ok=True)
7
 
 
8
  def inference(img_path, Style, if_face=None):
9
  print(img_path, Style, if_face)
10
  try:
 
30
  f = "U"
31
 
32
  try:
33
+ det_face = True if if_face == "Yes" else False
34
  output = AnimeGANv3_src.Convert(img, f, det_face)
35
  save_path = f"output/out.{img_path.rsplit('.')[-1]}"
36
  cv2.imwrite(save_path, output[:, :, ::-1])
 
41
  print('global exception', error)
42
  return None, None
43
 
 
44
  title = "AnimeGANv3: To produce your own animation."
45
  description = r"""Official online demo for <a href='https://github.com/TachibanaYoshino/AnimeGANv3' target='_blank'><b>AnimeGANv3</b></a>. If you like what I'm doing you can tip me on <a href='https://www.patreon.com/Asher_Chan' target='_blank'><b>**patreon**</b></a>.<br>
46
  It can be used to turn your photos or videos into anime.<br>
47
  To use it, simply upload your image. It can convert landscape photos to Hayao Miyazaki or Makoto Shinkai style anime, as well as 4 style conversions about human faces.<br>
48
  If AnimeGANv3 is helpful, please help to ⭐ the <a href='https://github.com/TachibanaYoshino/AnimeGANv3' target='_blank'>Github Repo</a> and recommend it to your friends. 😊
 
49
  """
 
50
 
51
+ article = r"""
52
  [![GitHub Stars](https://img.shields.io/github/stars/TachibanaYoshino/AnimeGANv3?style=social)](https://github.com/TachibanaYoshino/AnimeGANv3)
53
 
54
  ### 🗻 Demo
 
77
 
78
  <center><img src='https://visitor-badge.glitch.me/badge?page_id=AnimeGANv3_online' alt='visitor badge'></center>
79
  """
80
+
81
+ iface = gr.Interface(
82
+ fn=inference,
83
+ inputs=[
84
  gr.Image(type="filepath", label="Input"),
85
+ gr.Dropdown(
86
+ [
87
+ 'AnimeGANv3_Hayao',
88
+ 'AnimeGANv3_Shinkai',
89
+ 'AnimeGANv3_Arcane',
90
+ 'AnimeGANv3_USA',
91
+ 'AnimeGANv3_Trump v1.0',
92
+ 'AnimeGANv3_Disney v1.0',
93
+ 'AnimeGANv3_PortraitSketch',
94
+ 'AnimeGANv3_JP_face v1.0',
95
+ 'AnimeGANv3_Kpop v2.0',
96
+ ],
97
  type="value",
98
  value='AnimeGANv3_Hayao',
99
+ label='AnimeGANv3 Style'
100
+ ),
101
  gr.Radio(['Yes', 'No'], type="value", value='No', label='Extract face'),
102
+ ],
103
+ outputs=[
104
  gr.Image(type="numpy", label="Output (The whole image)"),
105
  gr.File(label="Download the output image")
106
  ],
107
  title=title,
108
  description=description,
109
  article=article,
110
+ allow_flagging="never"
111
+ )
112
+
113
+ iface.launch()