vumichien commited on
Commit
f9ab238
·
1 Parent(s): c270194

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -5
app.py CHANGED
@@ -95,8 +95,14 @@ MODEL_PATH = {
95
  }
96
 
97
 
98
- def inference(img_path, model, focus_face=None):
99
- print(img_path, model, focus_face)
 
 
 
 
 
 
100
  mat, scale = load_image(img_path, focus_face)
101
  output = convert(mat, model, scale)
102
  save_path = f"output/out.{img_path.rsplit('.')[-1]}"
@@ -109,8 +115,9 @@ title = "AnimeGANv2: To produce your own animation 😶‍🌫️"
109
  description = r"""
110
  ### 🔥Demo AnimeGANv2: To produce your own animation. <br>
111
  #### How to use:
112
- 1. Upload your image
113
- 2. Select the style (*For human*: PortraitSketch, JP_face; *For scene*: Hayao, Shinkai, Paprika)
 
114
  3. Choice of whether to extract the face.(Warning: Yes if there is a face in the image)
115
  """
116
  article = r"""
@@ -125,7 +132,8 @@ examples=[['sample1.jpg', 'PortraitSketch', "Yes"],
125
  ['sample6.jpeg', 'JP_face', "No"]]
126
  gr.Interface(
127
  inference, [
128
- gr.Image(type="filepath", label="Input image"),
 
129
  gr.Dropdown([
130
  'Hayao',
131
  'Shinkai',
 
95
  }
96
 
97
 
98
+ def inference(upload, webcam, model, focus_face=None):
99
+ print(upload, webcam, model, focus_face)
100
+ if upload is not None:
101
+ img_path = upload
102
+ elif upload is None and webcam is not None:
103
+ img_path = webcam
104
+ else:
105
+ img_path = ""
106
  mat, scale = load_image(img_path, focus_face)
107
  output = convert(mat, model, scale)
108
  save_path = f"output/out.{img_path.rsplit('.')[-1]}"
 
115
  description = r"""
116
  ### 🔥Demo AnimeGANv2: To produce your own animation. <br>
117
  #### How to use:
118
+ 1a. Upload your image
119
+ 1b. Use webcam to take an image
120
+ 2. Select the style (**For human**: PortraitSketch, JP_face; **For scene**: Hayao, Shinkai, Paprika)
121
  3. Choice of whether to extract the face.(Warning: Yes if there is a face in the image)
122
  """
123
  article = r"""
 
132
  ['sample6.jpeg', 'JP_face', "No"]]
133
  gr.Interface(
134
  inference, [
135
+ gr.Image(type="filepath", label="Image", source="upload"),
136
+ gr.Image(type="filepath", label="Webcam", source="webcam"),
137
  gr.Dropdown([
138
  'Hayao',
139
  'Shinkai',