Spaces:
Running
Running
Upload app.py
Browse files
app.py
CHANGED
@@ -36,10 +36,14 @@ def analyze_images(image1, image2, api_key, org_id):
|
|
36 |
response = response['entry']
|
37 |
print(response.keys())
|
38 |
|
|
|
|
|
|
|
|
|
39 |
if response['status'] == 'success':
|
40 |
-
return {key: value for key, value in response.items() if key != 'avatar'}
|
41 |
else:
|
42 |
-
return f"Request failed: {response['text']}"
|
43 |
|
44 |
|
45 |
def assign_sample_images():
|
@@ -59,10 +63,12 @@ with gr.Blocks() as demo:
|
|
59 |
|
60 |
sample_button = gr.Button("サンプル画像")
|
61 |
analyze_button = gr.Button("解析", variant='primary')
|
62 |
-
|
|
|
|
|
63 |
|
64 |
sample_button.click(assign_sample_images, inputs=[], outputs=[image1, image2])
|
65 |
-
analyze_button.click(analyze_images, inputs=[image1, image2, api_key, org_id], outputs=[result])
|
66 |
|
67 |
if __name__ == '__main__':
|
68 |
demo.launch()
|
|
|
36 |
response = response['entry']
|
37 |
print(response.keys())
|
38 |
|
39 |
+
obj_path = 'avatar.obj'
|
40 |
+
with open(obj_path, 'wb') as avatar_file:
|
41 |
+
avatar_file.write(base64.b64decode(response['avatar']['data']))
|
42 |
+
|
43 |
if response['status'] == 'success':
|
44 |
+
return {key: value for key, value in response.items() if key != 'avatar'}, obj_path
|
45 |
else:
|
46 |
+
return f"Request failed: {response['text']}", ''
|
47 |
|
48 |
|
49 |
def assign_sample_images():
|
|
|
63 |
|
64 |
sample_button = gr.Button("サンプル画像")
|
65 |
analyze_button = gr.Button("解析", variant='primary')
|
66 |
+
with gr.Row():
|
67 |
+
avatar_model = gr.Model3D(label="アバター")
|
68 |
+
result = gr.TextArea(label="解析結果")
|
69 |
|
70 |
sample_button.click(assign_sample_images, inputs=[], outputs=[image1, image2])
|
71 |
+
analyze_button.click(analyze_images, inputs=[image1, image2, api_key, org_id], outputs=[result, avatar_model])
|
72 |
|
73 |
if __name__ == '__main__':
|
74 |
demo.launch()
|