
* 겪고 있는 문제 상황을 최대한 자세하게 작성해주세요.
* 문제 해결을 위해 어떤 시도를 해보았는지 구체적으로 함께 알려주세요.
질문 내용Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/gradio/queueing.py", line 427, in call_prediction
output = await route_utils.call_process_api(
File "/usr/local/lib/python3.10/dist-packages/gradio/route_utils.py", line 232, in call_process_api
output = await app.get_blocks().process_api(
File "/usr/local/lib/python3.10/dist-packages/gradio/blocks.py", line 1497, in process_api
result = await self.call_function(
File "/usr/local/lib/python3.10/dist-packages/gradio/blocks.py", line 1119, in call_function
prediction = await anyio.to_thread.run_sync(
File "/usr/local/lib/python3.10/dist-packages/anyio/to_thread.py", line 33, in run_sync
return await get_asynclib().run_sync_in_worker_thread(
File "/usr/local/lib/python3.10/dist-packages/anyio/_backends/_asyncio.py", line 877, in run_sync_in_worker_thread
return await future
File "/usr/local/lib/python3.10/dist-packages/anyio/_backends/_asyncio.py", line 807, in run
result = context.run(func, *args)
File "/usr/local/lib/python3.10/dist-packages/gradio/utils.py", line 665, in wrapper
response = f(*args, **kwargs)
File "<ipython-input-45-495502181ed4>", line 8, in bmi
if emotion >= 23:
TypeError: '>=' not supported between instances of 'str' and 'int'
Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/gradio/queueing.py", line 427, in call_prediction
output = await route_utils.call_process_api(
File "/usr/local/lib/python3.10/dist-packages/gradio/route_utils.py", line 232, in call_process_api
output = await app.get_blocks().process_api(
File "/usr/local/lib/python3.10/dist-packages/gradio/blocks.py", line 1497, in process_api
result = await self.call_function(
File "/usr/local/lib/python3.10/dist-packages/gradio/blocks.py", line 1119, in call_function
prediction = await anyio.to_thread.run_sync(
File "/usr/local/lib/python3.10/dist-packages/anyio/to_thread.py", line 33, in run_sync
return await get_asynclib().run_sync_in_worker_thread(
File "/usr/local/lib/python3.10/dist-packages/anyio/_backends/_asyncio.py", line 877, in run_sync_in_worker_thread
return await future
File "/usr/local/lib/python3.10/dist-packages/anyio/_backends/_asyncio.py", line 807, in run
result = context.run(func, *args)
File "/usr/local/lib/python3.10/dist-packages/gradio/utils.py", line 665, in wrapper
response = f(*args, **kwargs)
File "<ipython-input-45-495502181ed4>", line 8, in bmi
if emotion >= 23:
TypeError: '>=' not supported between instances of 'str' and 'int'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/gradio/queueing.py", line 472, in process_events
response = await self.call_prediction(awake_events, batch)
File "/usr/local/lib/python3.10/dist-packages/gradio/queueing.py", line 436, in call_prediction
raise Exception(str(error) if show_error else None) from error
Exception: None
이렇게 에러 발생함. 코드도 정상적으로 입력했는데 말이죠. 코드 수정해 주세요 코드는 아래와 같음
import gradio as gr
def bmi(name,height,weight,diet):
bmi_val = round(weight / ((height /100)**2),2)
emotion= ""
if emotion >= 23:
emotion ="bad"
else:
emotion = "good"
if diet:
diet ="다이어트 중"
else:
diet =" 살찌는 중"
return (f"안녕하세요 {name}님 당신의 bmi지수는 {bmi_val}입니다", emotion, diet)
interface = gr.Interface(
fn=bmi,
inputs=["text",gr.Slider(0,300, label="키(cm)"),gr.Slider(0,150,label= "몸무게(kg)"),gr.Checkbox(label="다이어트 여부")],
outputs=["text","text","text"],
)
interface.launch(debug=True)ㅌ
