Clean method to prevent gradio from phoning home

This commit is contained in:
oobabooga 2023-04-18 03:56:20 -03:00 committed by GitHub
parent 8275989f03
commit c58c1d89bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,10 +1,21 @@
import os import os
import requests
import warnings import warnings
os.environ['GRADIO_ANALYTICS_ENABLED'] = 'False' os.environ['GRADIO_ANALYTICS_ENABLED'] = 'False'
os.environ['BITSANDBYTES_NOWELCOME'] = '1' os.environ['BITSANDBYTES_NOWELCOME'] = '1'
warnings.filterwarnings('ignore', category=UserWarning, message='TypedStorage is deprecated') warnings.filterwarnings('ignore', category=UserWarning, message='TypedStorage is deprecated')
#from modules import dirty_patch_gradio
# This is a hack to prevent Gradio from phoning home when it gets imported
def my_get(url, **kwargs):
print('Gradio HTTP request redirected to localhost :)')
kwargs.setdefault('allow_redirects', True)
return requests.api.request('get', 'http://127.0.0.1/', **kwargs)
original_get = requests.get
requests.get = my_get
import gradio as gr
requests.get = original_get
import importlib import importlib
import io import io
@ -19,7 +30,6 @@ import zipfile
from datetime import datetime from datetime import datetime
from pathlib import Path from pathlib import Path
import gradio as gr
import psutil import psutil
import torch import torch
import yaml import yaml