wahaha commited on
Commit
14dc1a2
1 Parent(s): 03dcde3
Files changed (1) hide show
  1. app.py +91 -0
app.py ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+
3
+ from __future__ import annotations
4
+ import argparse
5
+ import functools
6
+ import os
7
+ import pathlib
8
+ import sys
9
+ from typing import Callable
10
+
11
+
12
+ import gradio as gr
13
+ import huggingface_hub
14
+ import numpy as np
15
+ import PIL.Image
16
+
17
+ from io import BytesIO
18
+
19
+
20
+ ORIGINAL_REPO_URL = 'https://github.com/TachibanaYoshino/AnimeGANv2'
21
+ TITLE = 'TachibanaYoshino/AnimeGANv2'
22
+ DESCRIPTION = f"""This is a demo for {ORIGINAL_REPO_URL}.
23
+
24
+ """
25
+ ARTICLE = """
26
+
27
+ """
28
+
29
+
30
+ def parse_args() -> argparse.Namespace:
31
+ parser = argparse.ArgumentParser()
32
+ parser.add_argument('--device', type=str, default='cpu')
33
+ parser.add_argument('--theme', type=str)
34
+ parser.add_argument('--live', action='store_true')
35
+ parser.add_argument('--share', action='store_true')
36
+ parser.add_argument('--port', type=int)
37
+ parser.add_argument('--disable-queue',
38
+ dest='enable_queue',
39
+ action='store_false')
40
+ parser.add_argument('--allow-flagging', type=str, default='never')
41
+ parser.add_argument('--allow-screenshot', action='store_true')
42
+ return parser.parse_args()
43
+
44
+
45
+
46
+
47
+ def run(
48
+ image,
49
+ ) -> tuple[PIL.Image.Image]:
50
+
51
+
52
+ return PIL.Image.open(image.name)
53
+
54
+
55
+ def main():
56
+ gr.close_all()
57
+
58
+ args = parse_args()
59
+
60
+
61
+ func = functools.partial(run)
62
+ func = functools.update_wrapper(func, run)
63
+
64
+
65
+ gr.Interface(
66
+ func,
67
+ [
68
+ gr.inputs.Image(type='file', label='Input Image'),
69
+ ],
70
+ [
71
+ gr.outputs.Image(
72
+ type='pil',
73
+ label='Result'),
74
+ ],
75
+ #examples=examples,
76
+ theme=args.theme,
77
+ title=TITLE,
78
+ description=DESCRIPTION,
79
+ article=ARTICLE,
80
+ allow_screenshot=args.allow_screenshot,
81
+ allow_flagging=args.allow_flagging,
82
+ live=args.live,
83
+ ).launch(
84
+ enable_queue=args.enable_queue,
85
+ server_port=args.port,
86
+ share=args.share,
87
+ )
88
+
89
+
90
+ if __name__ == '__main__':
91
+ main()