Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -33,7 +33,7 @@ def respond(message, history):
|
|
33 |
|
34 |
# プロンプトの作成
|
35 |
prompt = pd.DataFrame(
|
36 |
-
{"
|
37 |
)
|
38 |
|
39 |
print(prompt)
|
@@ -46,37 +46,13 @@ def respond(message, history):
|
|
46 |
# モデルサービングエンドポイントに問い合わせ
|
47 |
response = requests.request(method="POST", headers=headers, url=local_endpoint, data=data_json)
|
48 |
response_data = response.json()
|
49 |
-
|
50 |
-
|
51 |
-
# numpy arrayに変換
|
52 |
-
im_array = np.array(response_data["predictions"], dtype=np.uint8)
|
53 |
-
#print(im_array)
|
54 |
-
# 画像に変換
|
55 |
-
im = Image.fromarray(im_array, 'RGB')
|
56 |
-
|
57 |
-
|
58 |
-
# debug
|
59 |
-
#image_url = "https://upload.wikimedia.org/wikipedia/commons/thumb/e/ec/Mona_Lisa,_by_Leonardo_da_Vinci,_from_C2RMF_retouched.jpg/687px-Mona_Lisa,_by_Leonardo_da_Vinci,_from_C2RMF_retouched.jpg"
|
60 |
-
#print("image_url:", image_url)
|
61 |
-
#im = Image.open(io.BytesIO(requests.get(image_url).content))
|
62 |
-
#numpydata = np.asarray(im)
|
63 |
-
|
64 |
-
rawBytes = io.BytesIO()
|
65 |
-
im.save(rawBytes, "PNG")
|
66 |
-
rawBytes.seek(0) # ファイルの先頭に移動
|
67 |
-
# base64にエンコード
|
68 |
-
image_encoded = base64.b64encode(rawBytes.read()).decode('ascii')
|
69 |
-
#print(image_encoded)
|
70 |
-
|
71 |
-
# マークダウンに埋め込み
|
72 |
-
embed_image_markdown = f""
|
73 |
-
#print(embed_image_markdown)
|
74 |
|
75 |
except Exception as error:
|
76 |
response_data = f"ERROR status_code: {type(error).__name__}"
|
77 |
#+ str(response.status_code) + " response:" + response.text
|
78 |
|
79 |
-
return
|
80 |
|
81 |
|
82 |
theme = gr.themes.Soft(
|
|
|
33 |
|
34 |
# プロンプトの作成
|
35 |
prompt = pd.DataFrame(
|
36 |
+
{"query": [message]}
|
37 |
)
|
38 |
|
39 |
print(prompt)
|
|
|
46 |
# モデルサービングエンドポイントに問い合わせ
|
47 |
response = requests.request(method="POST", headers=headers, url=local_endpoint, data=data_json)
|
48 |
response_data = response.json()
|
49 |
+
print(response_data["predictions"])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
|
51 |
except Exception as error:
|
52 |
response_data = f"ERROR status_code: {type(error).__name__}"
|
53 |
#+ str(response.status_code) + " response:" + response.text
|
54 |
|
55 |
+
return response_data["predictions"]
|
56 |
|
57 |
|
58 |
theme = gr.themes.Soft(
|