| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
|
|
| import fileinput |
| import site |
|
|
| import gradio_client.utils as gradio_client_utils |
|
|
|
|
| def _patch_gradio_schema_bool_bug() -> None: |
| """Patch schema parser for bool-style for gradio<5.33.""" |
| original_get_type = gradio_client_utils.get_type |
| original_json_schema_to_python_type = ( |
| gradio_client_utils._json_schema_to_python_type |
| ) |
|
|
| def _safe_get_type(schema): |
| if isinstance(schema, bool): |
| return {} |
| return original_get_type(schema) |
|
|
| def _safe_json_schema_to_python_type(schema, defs): |
| if isinstance(schema, bool): |
| return "Any" |
| return original_json_schema_to_python_type(schema, defs) |
|
|
| gradio_client_utils.get_type = _safe_get_type |
| gradio_client_utils._json_schema_to_python_type = ( |
| _safe_json_schema_to_python_type |
| ) |
|
|
|
|
| def _patch_open3d_cuda_device_count_bug() -> None: |
| """Patch open3d to avoid cuda device count bug.""" |
| with fileinput.FileInput( |
| f'{site.getsitepackages()[0]}/open3d/__init__.py', inplace=True |
| ) as file: |
| for line in file: |
| print( |
| line.replace( |
| '_pybind_cuda.open3d_core_cuda_device_count()', '1' |
| ), |
| end='', |
| ) |
|
|