Spaces:
Running
on
Zero
Running
on
Zero
Commit
·
8fbff22
1
Parent(s):
082831f
compile
Browse files- app.py +4 -1
- requirements.txt +1 -1
app.py
CHANGED
|
@@ -5,13 +5,16 @@ import tempfile
|
|
| 5 |
from PIL import Image, ImageDraw, ImageFont
|
| 6 |
from transformers import RTDetrForObjectDetection, RTDetrImageProcessor
|
| 7 |
import torch
|
|
|
|
| 8 |
|
| 9 |
image_processor = RTDetrImageProcessor.from_pretrained("PekingU/rtdetr_r50vd")
|
| 10 |
model = RTDetrForObjectDetection.from_pretrained("PekingU/rtdetr_r50vd", torch_dtype=torch.float16).to("cuda")
|
| 11 |
model = torch.compile(model, mode="reduce-overhead")
|
| 12 |
|
| 13 |
# Compile by running inference
|
| 14 |
-
|
|
|
|
|
|
|
| 15 |
with torch.no_grad():
|
| 16 |
outputs = model(**inputs)
|
| 17 |
|
|
|
|
| 5 |
from PIL import Image, ImageDraw, ImageFont
|
| 6 |
from transformers import RTDetrForObjectDetection, RTDetrImageProcessor
|
| 7 |
import torch
|
| 8 |
+
import requests
|
| 9 |
|
| 10 |
image_processor = RTDetrImageProcessor.from_pretrained("PekingU/rtdetr_r50vd")
|
| 11 |
model = RTDetrForObjectDetection.from_pretrained("PekingU/rtdetr_r50vd", torch_dtype=torch.float16).to("cuda")
|
| 12 |
model = torch.compile(model, mode="reduce-overhead")
|
| 13 |
|
| 14 |
# Compile by running inference
|
| 15 |
+
url = 'http://images.cocodataset.org/val2017/000000039769.jpg'
|
| 16 |
+
image = Image.open(requests.get(url, stream=True).raw)
|
| 17 |
+
inputs = image_processor(images=image, return_tensors="pt").to("cuda", torch.float16)
|
| 18 |
with torch.no_grad():
|
| 19 |
outputs = model(**inputs)
|
| 20 |
|
requirements.txt
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
safetensors==0.4.3
|
| 2 |
-
transformers
|
| 3 |
gradio-client @ git+https://github.com/gradio-app/gradio@66349fe26827e3a3c15b738a1177e95fec7f5554#subdirectory=client/python
|
| 4 |
https://gradio-pypi-previews.s3.amazonaws.com/66349fe26827e3a3c15b738a1177e95fec7f5554/gradio-4.42.0-py3-none-any.whl
|
|
|
|
| 1 |
safetensors==0.4.3
|
| 2 |
+
transformers @ git+https://github.com/yonigozlan/transformers@optim-rt-detr
|
| 3 |
gradio-client @ git+https://github.com/gradio-app/gradio@66349fe26827e3a3c15b738a1177e95fec7f5554#subdirectory=client/python
|
| 4 |
https://gradio-pypi-previews.s3.amazonaws.com/66349fe26827e3a3c15b738a1177e95fec7f5554/gradio-4.42.0-py3-none-any.whl
|