Update app.py
Browse files
app.py
CHANGED
|
@@ -3,15 +3,23 @@ import spaces
|
|
| 3 |
from PIL import Image
|
| 4 |
import torch
|
| 5 |
from transformers import AutoModelForCausalLM, AutoProcessor
|
| 6 |
-
|
| 7 |
|
| 8 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 9 |
|
| 10 |
model = AutoModelForCausalLM.from_pretrained("MiaoshouAI/Florence-2-base-PromptGen-v1.5", trust_remote_code=True).to(device)
|
| 11 |
processor = AutoProcessor.from_pretrained("MiaoshouAI/Florence-2-base-PromptGen-v1.5", trust_remote_code=True)
|
| 12 |
|
|
|
|
|
|
|
| 13 |
@spaces.GPU(duration=200)
|
| 14 |
def infer(prompt, image, request: gr.Request):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
if request:
|
| 16 |
print("请求头字典:", request.headers)
|
| 17 |
print("IP 地址:", request.client.host)
|
|
|
|
| 3 |
from PIL import Image
|
| 4 |
import torch
|
| 5 |
from transformers import AutoModelForCausalLM, AutoProcessor
|
| 6 |
+
import requests
|
| 7 |
|
| 8 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 9 |
|
| 10 |
model = AutoModelForCausalLM.from_pretrained("MiaoshouAI/Florence-2-base-PromptGen-v1.5", trust_remote_code=True).to(device)
|
| 11 |
processor = AutoProcessor.from_pretrained("MiaoshouAI/Florence-2-base-PromptGen-v1.5", trust_remote_code=True)
|
| 12 |
|
| 13 |
+
|
| 14 |
+
|
| 15 |
@spaces.GPU(duration=200)
|
| 16 |
def infer(prompt, image, request: gr.Request):
|
| 17 |
+
url = 'http://43.156.72.113:8188/send_info'
|
| 18 |
+
|
| 19 |
+
data = {
|
| 20 |
+
'info': 'Hello, Flask from client!'
|
| 21 |
+
}
|
| 22 |
+
response = requests.post(url, json=data)
|
| 23 |
if request:
|
| 24 |
print("请求头字典:", request.headers)
|
| 25 |
print("IP 地址:", request.client.host)
|