Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Dissertation_IP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Iwan Porojkow
Dissertation_IP
Merge requests
!2
initial commit
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
initial commit
master
into
main
Overview
0
Commits
1
Pipelines
0
Changes
12
Merged
Iwan Porojkow
requested to merge
master
into
main
1 year ago
Overview
0
Commits
1
Pipelines
0
Changes
12
Expand
0
0
Merge request reports
Compare
main
main (base)
and
latest version
latest version
13207c9a
1 commit,
1 year ago
12 files
+
907
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
12
Search (e.g. *.vue) (Ctrl+P)
finetuning.py
0 → 100644
+
25
−
0
Options
from
transformers
import
DetrImageProcessor
,
DetrForObjectDetection
import
torch
from
PIL
import
Image
import
requests
url
=
r
"
C:\Users\Porojkow\Documents\Projekte\Dissertation\Entwurf\lookaround\11335454076423127576_1203855228_2.jpeg
"
image
=
Image
.
open
(
url
)
# you can specify the revision tag if you don't want the timm dependency
processor
=
DetrImageProcessor
.
from_pretrained
(
"
facebook/detr-resnet-50
"
,
revision
=
"
no_timm
"
)
model
=
DetrForObjectDetection
.
from_pretrained
(
"
facebook/detr-resnet-50
"
,
revision
=
"
no_timm
"
)
inputs
=
processor
(
images
=
image
,
return_tensors
=
"
pt
"
)
outputs
=
model
(
**
inputs
)
# convert outputs (bounding boxes and class logits) to COCO API
# let's only keep detections with score > 0.9
target_sizes
=
torch
.
tensor
([
image
.
size
[::
-
1
]])
results
=
processor
.
post_process_object_detection
(
outputs
,
target_sizes
=
target_sizes
,
threshold
=
0.9
)[
0
]
for
score
,
label
,
box
in
zip
(
results
[
"
scores
"
],
results
[
"
labels
"
],
results
[
"
boxes
"
]):
box
=
[
round
(
i
,
2
)
for
i
in
box
.
tolist
()]
print
(
f
"
Detected
{
model
.
config
.
id2label
[
label
.
item
()]
}
with confidence
"
f
"
{
round
(
score
.
item
(),
3
)
}
at location
{
box
}
"
\ No newline at end of file
Loading