A lightweight async alternative to gradio_client without heavy dependencies.
Project description
noob-gradio
A lightweight, async, dependency-free alternative to the official python
gradio_client— written for speed, simplicity, and control.
Features
- Fast & Async – built on top of
aiohttpandaiofiles, thats all - Smart Parameter Checking – validates types, min/max/step before sending
- Tiny Dependency Footprint – no heavy
huggingface_huband it's reqiurements (a lot) - Drop-in familiar syntax – like the official client, but simpler and async
Installation
pip install noob-gradio
Details
This project was inspired by the official gradio_client but rewritten to:
remove unnecessary dependencies,
run fully async,
and perform parameter validation before sending data to the server.
- gradio_client is ok, but it installs a ton of stuff, so this is a noob remake of it.
- Available functions: "handle_file", "client.predict" and "client.view_api".
- Client functions are async and must be awaited.
- The syntax is exacly the same as in official gradio_client.
Example
import asyncio
from noob_gradio import Client, handle_file
async def main():
async with Client("black-forest-labs/FLUX.1-schnell") as client:
result = await client.predict(
prompt="a cat sitting on a chair",
width=512,
height=512,
api_name="/infer",
)
print(result)
# you should get a path to downloaded image and image seed - (Result, Seed) or whatever the space returns
# to not download you can add download_files=False in Client
asyncio.run(main())
Also this supports the hf_token and other methods of creating a Client and session, here is example of everything
client = Client("black-forest-labs/FLUX.1-schnell", hf_token="secret", download_files=False, headers={"User-Agent": "gradio_real/1.0"})
async def main():
async with client:
# args and kwargs are suported
res = await client.predict("a white cat", width=512, api_name="/infer")
print(res)
# "async with" alternative
await client.connect()
await client.view_api()
# example file
file = handle_file("https://raw.githubusercontent.com/gradio-app/gradio/main/test/test_files/bus.png")
# also you can choose different space for each predict or view_api, with src
res = await client.predict(src="some space with file support", file=file, api_name="/predict")
print(res)
await client.close()
# "async with" or "connect+close" is required because its async
handle_file is needed for input of image or any file, local or from url - predict(image=handle_file("local_path_or_url"), ...)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file noob_gradio-1.0.0.tar.gz.
File metadata
- Download URL: noob_gradio-1.0.0.tar.gz
- Upload date:
- Size: 11.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
97b44da3b352d0ddb437290e6e267a4279a60711b6b6fdfd8c98b6e6c71df7ee
|
|
| MD5 |
f0fd28c722a8220ca6c29aad7b793ec5
|
|
| BLAKE2b-256 |
eb813b165ab49f774fe12f50bfc54d405f74ceb668c6e4f8133f7699fb2de203
|
File details
Details for the file noob_gradio-1.0.0-py3-none-any.whl.
File metadata
- Download URL: noob_gradio-1.0.0-py3-none-any.whl
- Upload date:
- Size: 9.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b375555688f4915cd1285ee27bd4d005d5022cd3d280764119ca40263df31394
|
|
| MD5 |
a0a08ae6bc3dd757e7a0363c36bf9b3b
|
|
| BLAKE2b-256 |
ca1a1ddc37ada6b579e449632ff4e2c849dd89d7d583653451adb1f6675404fa
|