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.
New in 1.0.1
You can pass existing session to Client, to reuse it.
import aiohttp
from noob_gradio import Client
async def main():
session = aiohttp.ClientSession()
client = Client("url", session=session)
# added in 1.0.2, will also work
client.set_session(session)
result = await client.predict(kwargs)
print(result)
# in on_close or similar event/function, at exit
await session.close()
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.3.tar.gz.
File metadata
- Download URL: noob_gradio-1.0.3.tar.gz
- Upload date:
- Size: 11.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
515cd8828484aff6ff9a40ffc7591e094dd9e31ceefd0caa98f6f8a67ba4ff56
|
|
| MD5 |
e06ea8e9b19cbe27d3597a787303396c
|
|
| BLAKE2b-256 |
d3d2963bc2e67db000ebb27a115c41469ad93f1ceb1cfe883ac16ea4fafbb945
|
Provenance
The following attestation bundles were made for noob_gradio-1.0.3.tar.gz:
Publisher:
python-publish.yml on Noob-Lol/noob-gradio
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
noob_gradio-1.0.3.tar.gz -
Subject digest:
515cd8828484aff6ff9a40ffc7591e094dd9e31ceefd0caa98f6f8a67ba4ff56 - Sigstore transparency entry: 780458194
- Sigstore integration time:
-
Permalink:
Noob-Lol/noob-gradio@d6f7eb8645b5cb1f77ca6e5416a50ef01e929807 -
Branch / Tag:
refs/tags/1.0.3 - Owner: https://github.com/Noob-Lol
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@d6f7eb8645b5cb1f77ca6e5416a50ef01e929807 -
Trigger Event:
release
-
Statement type:
File details
Details for the file noob_gradio-1.0.3-py3-none-any.whl.
File metadata
- Download URL: noob_gradio-1.0.3-py3-none-any.whl
- Upload date:
- Size: 9.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2d7383105a6ed937d0b9e3f231eb9ead6f21dbd1a8e03d492296027fb11673b6
|
|
| MD5 |
c15d95e888e08467c7145bae502ae3f0
|
|
| BLAKE2b-256 |
c8710ce66a53d6e101a7dd9a89b6d4895bd26160ae2a10fe9e31a4fb30be25e4
|
Provenance
The following attestation bundles were made for noob_gradio-1.0.3-py3-none-any.whl:
Publisher:
python-publish.yml on Noob-Lol/noob-gradio
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
noob_gradio-1.0.3-py3-none-any.whl -
Subject digest:
2d7383105a6ed937d0b9e3f231eb9ead6f21dbd1a8e03d492296027fb11673b6 - Sigstore transparency entry: 780458196
- Sigstore integration time:
-
Permalink:
Noob-Lol/noob-gradio@d6f7eb8645b5cb1f77ca6e5416a50ef01e929807 -
Branch / Tag:
refs/tags/1.0.3 - Owner: https://github.com/Noob-Lol
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@d6f7eb8645b5cb1f77ca6e5416a50ef01e929807 -
Trigger Event:
release
-
Statement type: