test2 / app.py
morinop's picture
Create app.py
218afdd
raw
history blame contribute delete
936 Bytes
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.ones([1,3,224,224])
# out = model(x)
return f"Hello {model.bn1.running_mean.data} !!"
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
iface.launch()