MiniGPT-4 icon indicating copy to clipboard operation
MiniGPT-4 copied to clipboard

Error while trying to use the gradio_client API (AttributeError: 'dict' object has no attribute 'replace')

Open alexandrosXe opened this issue 1 year ago • 14 comments

Congratulations on this fantastic job! I am trying to use the model with the gradio_client API (while the model is running on colab according to the colab tutorial)

Using the code from the API DOC:

========================== from gradio_client import Client

client = Client("https://158ba9997c4a402c80.gradio.live/") result = client.predict( "https://raw.githubusercontent.com/gradio-app/gradio/main/test/test_files/bus.png", # str representing filepath or URL to image in 'parameter_6' Image component "Howdy!", # str representing string value in 'User' Textbox component #null, # Any representing in 'parameter_13' State component fn_index=0 ) print(result)

I am getting the following error: AttributeError: 'dict' object has no attribute 'replace'

Could you please help me fix this problem?

Sincerely, Alexandros Xenos

alexandrosXe avatar Apr 26 '23 10:04 alexandrosXe

Hi Alexandros, I am getting the exact same issue. Did you happen to find a solution? Thanks.

nathanwangai avatar May 11 '23 00:05 nathanwangai

Hi Nathan, unfortunately not :(

alexandrosXe avatar May 11 '23 06:05 alexandrosXe

Same issue here -- anyone find a workaround?

katiefraser avatar May 16 '23 15:05 katiefraser

Using the code from the API DOC:

Sorry if I totally missed it, but where is the API doc? Looking for the schema currently.

wes-kay avatar Jun 11 '23 23:06 wes-kay

from gradio_client import Client

client = Client("Your_Public_URL")

# print(client.view_api(all_endpoints=True)) # uncomment this line to view all available API
client.submit("You_Test_Image.png", "describe the image", fn_index=0)
_, chatbot = client.predict("describe the image", "empty.json", fn_index=1)
chatbot = client.predict(chatbot, 1, 1, fn_index=2)
print(chatbot)

I think you can try this code to use the gradio_client API to call the miniGPT predict function. The empty.json is an json file with only "[]". The chatbot will be a json file path which save the conversation.

doublelei avatar Jun 13 '23 02:06 doublelei

client = Client("xxx", serialize=False)

don't serialize

wushaojun321 avatar Aug 24 '23 02:08 wushaojun321

client = Client("xxx", serialize=False)

don't serialize

Solved my problem, thank you!

shirubei avatar Aug 27 '23 16:08 shirubei

Still getting the same error even with serialize=False

AndreiMoiceanu29 avatar Sep 27 '23 14:09 AndreiMoiceanu29

+1

fazliimam avatar Oct 24 '23 18:10 fazliimam

Try this for MiniGPT V1:

image

akshayjoshii avatar Oct 27 '23 12:10 akshayjoshii

@wushaojun321 @TsuTikgiau @junchen14 I was able to use gradio_client with MiniGPT (see above comment). But it's not very clear on how to do this with MiniGPT v2 w/ LLaMa. Could you please provide a minimum viable script/steps to achieve this? Your help would be highly appreciated! Thanks!

akshayjoshii avatar Nov 01 '23 15:11 akshayjoshii

Still getting the same error even with serialize=False

After 'serialize=False', I've met the same issue in https://huggingface.co/spaces/Vision-CAIR/minigpt4/discussions/32

HUIZ-A avatar Feb 28 '24 15:02 HUIZ-A

Im having the same issue

Kamakshi8104 avatar Mar 27 '24 18:03 Kamakshi8104

非常不幸,我也遇到了相同的问题。我使用vscode连接linux服务器,运行后使用api,出现了相同的问题。使用“serialize=False”,也没有解决问题。

qinghuanyyz avatar May 31 '24 07:05 qinghuanyyz