Download call_api.py from kachaf/rawi-v3: direct link, hf CLI and curl.
- Browser
- Download file 1.16 kB
-
https://huggingface.co/spaces/kachaf/rawi-v3/resolve/main/call_api.py
- Command line
-
hf download hf://spaces/kachaf/rawi-v3/call_api.py
-
curl -L -o call_api.py https://huggingface.co/spaces/kachaf/rawi-v3/resolve/main/call_api.py
1.16 kB
| """ | |
| Client Python pour appeler le Space Gradio rawi-v3 déployé sur HuggingFace. | |
| Installation : | |
| pip install gradio_client | |
| Usage : | |
| python call_api.py "بسم الله الرحمن الرحيم" | |
| python call_api.py "يسوسون البلاد بغير علم" --space monusername/rawi-v3 | |
| Remplace SPACE_ID par "<ton-username>/rawi-v3" après déploiement. | |
| """ | |
| import sys | |
| import argparse | |
| from gradio_client import Client | |
| DEFAULT_SPACE = "VOTRE_USERNAME/rawi-v3" # <-- à mettre à jour après déploiement | |
| def diacritize(text: str, space: str = DEFAULT_SPACE) -> str: | |
| client = Client(space) | |
| result = client.predict( | |
| text, | |
| api_name="/predict", | |
| ) | |
| return result | |
| def main(): | |
| parser = argparse.ArgumentParser(description="Client Rawi V3 — tashkeel arabe") | |
| parser.add_argument("text", help="Texte arabe à diacritiser") | |
| parser.add_argument( | |
| "--space", | |
| default=DEFAULT_SPACE, | |
| help="ID du Space HuggingFace (ex: monusername/rawi-v3)", | |
| ) | |
| args = parser.parse_args() | |
| result = diacritize(args.text, args.space) | |
| print(result) | |
| if __name__ == "__main__": | |
| main() | |