Khanfar / gradio_patch.py
mhammad's picture
Upload folder using huggingface_hub
493d9a8 verified
raw
history blame
936 Bytes
# Patch for Gradio's 'bool' is not iterable error
import sys
def patch_gradio():
try:
import gradio_client.utils
# Store the original get_type function
original_get_type = gradio_client.utils.get_type
# Create a fixed version that handles booleans
def patched_get_type(schema):
if isinstance(schema, bool):
return "bool"
return original_get_type(schema)
# Replace the original function with our patched version
gradio_client.utils.get_type = patched_get_type
print("βœ… Gradio patch applied successfully")
except ImportError:
print("❌ Could not import gradio_client.utils to apply patch")
except Exception as e:
print(f"❌ Failed to apply Gradio patch: {str(e)}")
# Apply the patch immediately when this module is imported
patch_gradio()