Golf8 commited on
Commit
35172c9
Β·
verified Β·
1 Parent(s): 2e1ca4d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -44
app.py CHANGED
@@ -1,59 +1,27 @@
1
  import gradio as gr
2
- from PIL import Image
3
- import tempfile
4
  import os
5
 
6
- def upscale_images(files):
7
 
8
- results = []
9
 
10
- for file in files:
11
-
12
- img = Image.open(file)
13
-
14
- w, h = img.size
15
-
16
- img = img.resize(
17
- (w * 2, h * 2),
18
- Image.LANCZOS
19
- )
20
-
21
- output_path = os.path.join(
22
- tempfile.gettempdir(),
23
- f"upscaled_{os.path.basename(file)}"
24
- )
25
-
26
- img.save(output_path)
27
-
28
- results.append(output_path)
29
-
30
- return results
31
 
32
  with gr.Blocks() as demo:
33
 
34
  gr.Markdown("# AI Image Upscaler")
35
 
36
- gr.Markdown(
37
- "θ€‡ζ•°η”»εƒγ‚’γ‚’γƒƒγƒ—γƒ­γƒΌγƒ‰γ—γ¦ι«˜η”»θ³ͺεŒ–"
38
- )
39
-
40
- files = gr.File(
41
- file_count="multiple",
42
- label="η”»εƒγ‚’ιΈζŠž"
43
- )
44
 
45
- run_button = gr.Button(
46
- "倉換開始"
47
- )
48
-
49
- gallery = gr.Gallery(
50
- label="硐果"
51
- )
52
 
53
- run_button.click(
54
- upscale_images,
55
- inputs=files,
56
- outputs=gallery
57
  )
58
 
59
  demo.launch()
 
1
  import gradio as gr
2
+ import requests
 
3
  import os
4
 
5
+ HF_TOKEN = os.getenv("HF_TOKEN")
6
 
7
+ def check_api():
8
 
9
+ if HF_TOKEN:
10
+ return "βœ… HF_TOKEN θͺ­γΏθΎΌγΏζˆεŠŸ"
11
+ else:
12
+ return "❌ HF_TOKEN γŒθ¦‹γ€γ‹γ‚ŠγΎγ›γ‚“"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
 
14
  with gr.Blocks() as demo:
15
 
16
  gr.Markdown("# AI Image Upscaler")
17
 
18
+ btn = gr.Button("APIη’Ίθͺ")
 
 
 
 
 
 
 
19
 
20
+ result = gr.Textbox()
 
 
 
 
 
 
21
 
22
+ btn.click(
23
+ check_api,
24
+ outputs=result
 
25
  )
26
 
27
  demo.launch()