Spaces:
Runtime error
Runtime error
TK156
commited on
Commit
·
e5808c5
1
Parent(s):
b82f603
fix: 最小テストアプリでビルド修正
Browse files- Gradioのみのシンプルアプリ
- Hello Worldで動作確認
- app.py +7 -42
- requirements.txt +0 -2
app.py
CHANGED
@@ -1,48 +1,13 @@
|
|
1 |
import gradio as gr
|
2 |
-
import numpy as np
|
3 |
-
from PIL import Image
|
4 |
|
5 |
-
def
|
6 |
-
""
|
7 |
-
if image is None:
|
8 |
-
return None, None
|
9 |
-
|
10 |
-
try:
|
11 |
-
# 画像サイズ取得
|
12 |
-
width, height = image.size
|
13 |
-
|
14 |
-
# 上から下へのグラデーション
|
15 |
-
depth_array = np.zeros((height, width), dtype=np.uint8)
|
16 |
-
for y in range(height):
|
17 |
-
depth_array[y, :] = int(255 * y / height)
|
18 |
-
|
19 |
-
# カラー深度マップ作成(青から赤へ)
|
20 |
-
depth_colored = np.zeros((height, width, 3), dtype=np.uint8)
|
21 |
-
depth_colored[:, :, 0] = 255 - depth_array # 赤チャンネル
|
22 |
-
depth_colored[:, :, 2] = depth_array # 青チャンネル
|
23 |
-
|
24 |
-
depth_image = Image.fromarray(depth_colored)
|
25 |
-
|
26 |
-
return image, depth_image
|
27 |
-
|
28 |
-
except Exception as e:
|
29 |
-
print(f"Error: {e}")
|
30 |
-
return image, image
|
31 |
|
32 |
-
|
33 |
-
|
34 |
-
gr.
|
35 |
-
gr.
|
36 |
-
|
37 |
-
with gr.Row():
|
38 |
-
input_image = gr.Image(label="入力画像", type="pil")
|
39 |
-
output_depth = gr.Image(label="深度マップ")
|
40 |
-
|
41 |
-
input_image.change(
|
42 |
-
fn=create_depth_map,
|
43 |
-
inputs=input_image,
|
44 |
-
outputs=[input_image, output_depth]
|
45 |
-
)
|
46 |
|
47 |
if __name__ == "__main__":
|
48 |
demo.launch()
|
|
|
1 |
import gradio as gr
|
|
|
|
|
2 |
|
3 |
+
def hello(name):
|
4 |
+
return f"Hello {name}!"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
+
demo = gr.Interface(
|
7 |
+
fn=hello,
|
8 |
+
inputs=gr.Textbox(label="Name"),
|
9 |
+
outputs=gr.Textbox(label="Greeting")
|
10 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
if __name__ == "__main__":
|
13 |
demo.launch()
|
requirements.txt
CHANGED
@@ -1,3 +1 @@
|
|
1 |
-
pillow
|
2 |
-
numpy
|
3 |
gradio
|
|
|
|
|
|
|
1 |
gradio
|