Update app.py
Browse files
app.py
CHANGED
|
@@ -1,59 +1,27 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
|
| 3 |
-
import tempfile
|
| 4 |
import os
|
| 5 |
|
| 6 |
-
|
| 7 |
|
| 8 |
-
|
| 9 |
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 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.
|
| 37 |
-
"θ€ζ°η»εγγ’γγγγΌγγγ¦ι«η»θ³ͺε"
|
| 38 |
-
)
|
| 39 |
-
|
| 40 |
-
files = gr.File(
|
| 41 |
-
file_count="multiple",
|
| 42 |
-
label="η»εγιΈζ"
|
| 43 |
-
)
|
| 44 |
|
| 45 |
-
|
| 46 |
-
"ε€ζιε§"
|
| 47 |
-
)
|
| 48 |
-
|
| 49 |
-
gallery = gr.Gallery(
|
| 50 |
-
label="η΅ζ"
|
| 51 |
-
)
|
| 52 |
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 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()
|