submit demo to gradio blocks event

#1
by akhaliq HF staff - opened

Hi, great work on the demo combining stylegan-human and pifu, would be great to have this as a submission to the gradio blocks event this month for a chance to win prizes, for more info see: https://huggingface.co/Gradio-Blocks, and the invite link to join: https://huggingface.co/organizations/Gradio-Blocks/share/YyEmWbViPRZypvGSnZzGxmKEnJqnOqgKKx, thanks!

Unfortunately I haven't been able to get it working

iface=gr.Interface.load("spaces/radames/PIFu-Clothed-Human-Digitization")

seems to produce an error

@nagolinc oh wait error are you getting, the interface.load errors should have been fixed with this https://github.com/gradio-app/gradio/pull/1361

Fetching interface from: https://huggingface.co/spaces/radames/PIFu-Clothed-Human-Digitization
/home/user/.local/lib/python3.8/site-packages/gradio/deprecation.py:43: UserWarning: You have unused kwarg parameters in Model3D, please remove them: {'clearColor': [0.0, 0.0, 0.0, 0.0]}
warnings.warn(
Traceback (most recent call last):
File "/home/user/.local/lib/python3.8/site-packages/gradio/routes.py", line 281, in predict
output = await app.blocks.process_api(body, username, session_state)
File "/home/user/.local/lib/python3.8/site-packages/gradio/blocks.py", line 356, in process_api
predictions = await run_in_threadpool(block_fn.fn, *processed_input)
File "/home/user/.local/lib/python3.8/site-packages/starlette/concurrency.py", line 41, in run_in_threadpool
return await anyio.to_thread.run_sync(func, *args)
File "/home/user/.local/lib/python3.8/site-packages/anyio/to_thread.py", line 31, in run_sync
return await get_asynclib().run_sync_in_worker_thread(
File "/home/user/.local/lib/python3.8/site-packages/anyio/_backends/_asyncio.py", line 937, in run_sync_in_worker_thread
return await future
File "/home/user/.local/lib/python3.8/site-packages/anyio/_backends/_asyncio.py", line 867, in run
result = context.run(func, *args)
File "app.py", line 24, in generate_model
iface = gr.Interface.load("spaces/radames/PIFu-Clothed-Human-Digitization")
File "/home/user/.local/lib/python3.8/site-packages/gradio/interface.py", line 90, in load
return super().load(name=name, src=src, api_key=api_key, alias=alias, **kwargs)
File "/home/user/.local/lib/python3.8/site-packages/gradio/blocks.py", line 518, in load
return external.load_blocks_from_repo(name, src, api_key, alias, **kwargs)
File "/home/user/.local/lib/python3.8/site-packages/gradio/external.py", line 34, in load_blocks_from_repo
blocks: gradio.Blocks = factory_methods[src](name, api_key, alias, **kwargs)
File "/home/user/.local/lib/python3.8/site-packages/gradio/external.py", line 309, in get_spaces
return get_spaces_blocks(model_name, config)
File "/home/user/.local/lib/python3.8/site-packages/gradio/external.py", line 349, in get_spaces_blocks
return gradio.Blocks.from_config(config, fns)
File "/home/user/.local/lib/python3.8/site-packages/gradio/blocks.py", line 311, in from_config
event_method(fn=fn, **dependency)
File "/home/user/.local/lib/python3.8/site-packages/gradio/blocks.py", line 471, in exit
self.config = self.get_config_file()
File "/home/user/.local/lib/python3.8/site-packages/gradio/blocks.py", line 440, in get_config_file
"props": utils.delete_none(block.get_config())
File "/home/user/.local/lib/python3.8/site-packages/gradio/components.py", line 3590, in get_config
"components": [component.get_block_name() for component in self.components],
File "/home/user/.local/lib/python3.8/site-packages/gradio/components.py", line 3590, in
"components": [component.get_block_name() for component in self.components],
AttributeError: 'str' object has no attribute 'get_block_name'

@nagolinc , can you try updating the sdk_version : 3.0.10 in the README.md?

Okay, that got me farther!

Now I can load the interface, but calling it still doesn't work. Perhaps I'm calling it wrong?

code:

iface = gr.Interface.load("spaces/radames/PIFu-Clothed-Human-Digitization")
print("calling interface")
model,file=iface.fns[0].fn(img) #perhaps this is wrong?

result:

Fetching interface from: https://huggingface.co/spaces/radames/PIFu-Clothed-Human-Digitization
/home/user/.local/lib/python3.8/site-packages/gradio/deprecation.py:43: UserWarning: You have unused kwarg parameters in Model3D, please remove them: {'clearColor': [0.0, 0.0, 0.0, 0.0]}
  warnings.warn(
calling interface
Traceback (most recent call last):
  File "/home/user/.local/lib/python3.8/site-packages/gradio/external.py", line 335, in fn
    output = result["data"]
KeyError: 'data'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/user/.local/lib/python3.8/site-packages/gradio/routes.py", line 281, in predict
    output = await app.blocks.process_api(body, username, session_state)
  File "/home/user/.local/lib/python3.8/site-packages/gradio/blocks.py", line 356, in process_api
    predictions = await run_in_threadpool(block_fn.fn, *processed_input)
  File "/home/user/.local/lib/python3.8/site-packages/starlette/concurrency.py", line 41, in run_in_threadpool
    return await anyio.to_thread.run_sync(func, *args)
  File "/home/user/.local/lib/python3.8/site-packages/anyio/to_thread.py", line 31, in run_sync
    return await get_asynclib().run_sync_in_worker_thread(
  File "/home/user/.local/lib/python3.8/site-packages/anyio/_backends/_asyncio.py", line 937, in run_sync_in_worker_thread
    return await future
  File "/home/user/.local/lib/python3.8/site-packages/anyio/_backends/_asyncio.py", line 867, in run
    result = context.run(func, *args)
  File "app.py", line 26, in generate_model
    model,file=iface.fns[0].fn(img)
  File "/home/user/.local/lib/python3.8/site-packages/gradio/external.py", line 337, in fn
    raise KeyError(
KeyError: "Could not find 'data' key in response from external Space. Response received: {'error': 'list index out of range'}"

tagging @abidlabs for this issue, sorry for the delay, can you also open this issue on the gradio github: https://github.com/gradio-app/gradio/issues

BTW you can format code by putting it inside three backticks (like on GitHub). I've edited your post to do it. Thanks!

Created issue here

Sign up or log in to comment