import gradio as gr import requests import torch def request_url(url): headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) ' 'Chrome/88.0.4324.146 Safari/537.36', } try: response = requests.get(url=url, headers=headers) if response.status_code == 200: return response.text except requests.RequestException: return None import timm model = timm.create_model("hf_hub:nateraw/resnet18-random", pretrained=True) model.train() import os def greet(name): # url = f'https://huggingface.co./spaces?p=1&sort=modified&search=GPT' # html = request_url(url) # key = os.getenv("OPENAI_API_KEY") x = torch.randn(1,3,224,224) out = model(x) return f"Hello {out.shape} !!" iface = gr.Interface(fn=greet, inputs="text", outputs="text") iface.launch()