Spaces:
Sleeping
Sleeping
Download gradio_patch.py from vinayedula/RefDiffNet: direct link, hf CLI and curl.
- Browser
- Download file 998 Bytes
-
https://huggingface.co/spaces/vinayedula/RefDiffNet/resolve/3fd90d538f3a8a36ff95b4ae4d39d733b8e163eb/gradio_patch.py
- Command line
-
hf download hf://spaces/vinayedula/RefDiffNet@3fd90d538f3a8a36ff95b4ae4d39d733b8e163eb/gradio_patch.py
-
curl -L -o gradio_patch.py https://huggingface.co/spaces/vinayedula/RefDiffNet/resolve/3fd90d538f3a8a36ff95b4ae4d39d733b8e163eb/gradio_patch.py
998 Bytes
| """Patch gradio_client JSON-schema helpers (bool additionalProperties with pydantic v2).""" | |
| from __future__ import annotations | |
| def apply() -> None: | |
| try: | |
| import gradio_client.utils as gc_utils | |
| except ImportError: | |
| return | |
| if getattr(gc_utils, "_refdiffnet_patched", False): | |
| return | |
| _orig_get_type = gc_utils.get_type | |
| def get_type(schema): # type: ignore[no-untyped-def] | |
| if not isinstance(schema, dict): | |
| return "Any" | |
| return _orig_get_type(schema) | |
| gc_utils.get_type = get_type # type: ignore[assignment] | |
| _orig_json = gc_utils._json_schema_to_python_type | |
| def _json_schema_to_python_type(schema, defs): # type: ignore[no-untyped-def] | |
| if not isinstance(schema, dict): | |
| return "Any" | |
| return _orig_json(schema, defs) | |
| gc_utils._json_schema_to_python_type = _json_schema_to_python_type # type: ignore[assignment] | |
| gc_utils._refdiffnet_patched = True # type: ignore[attr-defined] | |