forked from comfyanonymous/ComfyUI
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
448d926
commit 6adfb0f
Showing
37 changed files
with
13,786 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import os | ||
HOME = os.getcwd() | ||
print(HOME) | ||
|
||
|
||
%cd {HOME} | ||
!git clone https://github.com/IDEA-Research/GroundingDINO.git | ||
%cd {HOME}/GroundingDINO | ||
!pip install -q -e . | ||
!pip install -q roboflow | ||
|
||
|
||
import os | ||
|
||
CONFIG_PATH = os.path.join(HOME, "GroundingDINO/groundingdino/config/GroundingDINO_SwinT_OGC.py") | ||
print(CONFIG_PATH, "; exist:", os.path.isfile(CONFIG_PATH)) | ||
|
||
|
||
%cd {HOME} | ||
!mkdir {HOME}/weights | ||
%cd {HOME}/weights | ||
|
||
!wget -q https://github.com/IDEA-Research/GroundingDINO/releases/download/v0.1.0-alpha/groundingdino_swint_ogc.pth | ||
|
||
|
||
import os | ||
|
||
WEIGHTS_NAME = "groundingdino_swint_ogc.pth" | ||
WEIGHTS_PATH = os.path.join(HOME, "weights", WEIGHTS_NAME) | ||
print(WEIGHTS_PATH, "; exist:", os.path.isfile(WEIGHTS_PATH)) | ||
|
||
|
||
%cd {HOME}/GroundingDINO | ||
|
||
from groundingdino.util.inference import load_model, load_image, predict, annotate | ||
|
||
model = load_model(CONFIG_PATH, WEIGHTS_PATH) | ||
|
||
|
||
|
||
import os | ||
import supervision as sv | ||
|
||
IMAGE_NAME = "dog-3.jpeg" | ||
IMAGE_PATH = os.path.join(HOME, "data", IMAGE_NAME) | ||
|
||
TEXT_PROMPT = "chair" | ||
BOX_TRESHOLD = 0.35 | ||
TEXT_TRESHOLD = 0.25 | ||
|
||
image_source, image = load_image(IMAGE_PATH) | ||
|
||
boxes, logits, phrases = predict( | ||
model=model, | ||
image=image, | ||
caption=TEXT_PROMPT, | ||
box_threshold=BOX_TRESHOLD, | ||
text_threshold=TEXT_TRESHOLD | ||
) | ||
|
||
annotated_frame = annotate(image_source=image_source, boxes=boxes, logits=logits, phrases=phrases) | ||
|
||
%matplotlib inline | ||
sv.plot_image(annotated_frame, (16, 16)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,210 @@ | ||
{ | ||
"last_node_id": 25, | ||
"last_link_id": 38, | ||
"nodes": [ | ||
{ | ||
"id": 6, | ||
"type": "LoadImage", | ||
"pos": [ | ||
1360, | ||
1041 | ||
], | ||
"size": { | ||
"0": 220, | ||
"1": 320 | ||
}, | ||
"flags": {}, | ||
"order": 0, | ||
"mode": 0, | ||
"outputs": [ | ||
{ | ||
"name": "IMAGE", | ||
"type": "IMAGE", | ||
"links": [ | ||
34 | ||
], | ||
"shape": 3, | ||
"slot_index": 0 | ||
}, | ||
{ | ||
"name": "MASK", | ||
"type": "MASK", | ||
"links": null, | ||
"shape": 3 | ||
} | ||
], | ||
"properties": { | ||
"Node name for S&R": "LoadImage" | ||
}, | ||
"widgets_values": [ | ||
"Mia_face (28).png", | ||
"image" | ||
] | ||
}, | ||
{ | ||
"id": 24, | ||
"type": "SaveImage", | ||
"pos": [ | ||
1666, | ||
1090 | ||
], | ||
"size": { | ||
"0": 517.3851318359375, | ||
"1": 779.9139404296875 | ||
}, | ||
"flags": {}, | ||
"order": 3, | ||
"mode": 0, | ||
"inputs": [ | ||
{ | ||
"name": "images", | ||
"type": "IMAGE", | ||
"link": 37, | ||
"slot_index": 0 | ||
} | ||
], | ||
"properties": {}, | ||
"widgets_values": [ | ||
"mia/mia" | ||
], | ||
"color": "#222", | ||
"bgcolor": "#000" | ||
}, | ||
{ | ||
"id": 25, | ||
"type": "LoadImage", | ||
"pos": [ | ||
987, | ||
1361 | ||
], | ||
"size": { | ||
"0": 315, | ||
"1": 314.00006103515625 | ||
}, | ||
"flags": {}, | ||
"order": 1, | ||
"mode": 0, | ||
"outputs": [ | ||
{ | ||
"name": "IMAGE", | ||
"type": "IMAGE", | ||
"links": [ | ||
38 | ||
], | ||
"shape": 3, | ||
"slot_index": 0 | ||
}, | ||
{ | ||
"name": "MASK", | ||
"type": "MASK", | ||
"links": null, | ||
"shape": 3 | ||
} | ||
], | ||
"properties": { | ||
"Node name for S&R": "LoadImage" | ||
}, | ||
"widgets_values": [ | ||
"5.jpg", | ||
"image" | ||
] | ||
}, | ||
{ | ||
"id": 18, | ||
"type": "ReActorFaceSwap", | ||
"pos": [ | ||
1320, | ||
1418 | ||
], | ||
"size": { | ||
"0": 315, | ||
"1": 338 | ||
}, | ||
"flags": {}, | ||
"order": 2, | ||
"mode": 0, | ||
"inputs": [ | ||
{ | ||
"name": "source_image", | ||
"type": "IMAGE", | ||
"link": 34, | ||
"slot_index": 0 | ||
}, | ||
{ | ||
"name": "input_image", | ||
"type": "IMAGE", | ||
"link": 38, | ||
"slot_index": 1 | ||
}, | ||
{ | ||
"name": "face_model", | ||
"type": "FACE_MODEL", | ||
"link": null | ||
} | ||
], | ||
"outputs": [ | ||
{ | ||
"name": "IMAGE", | ||
"type": "IMAGE", | ||
"links": [ | ||
37 | ||
], | ||
"shape": 3, | ||
"slot_index": 0 | ||
}, | ||
{ | ||
"name": "FACE_MODEL", | ||
"type": "FACE_MODEL", | ||
"links": null, | ||
"shape": 3 | ||
} | ||
], | ||
"properties": { | ||
"Node name for S&R": "ReActorFaceSwap" | ||
}, | ||
"widgets_values": [ | ||
true, | ||
"inswapper_128.onnx", | ||
"retinaface_resnet50", | ||
"codeformer.pth", | ||
1, | ||
1, | ||
"female", | ||
"female", | ||
"0", | ||
"0", | ||
1 | ||
] | ||
} | ||
], | ||
"links": [ | ||
[ | ||
34, | ||
6, | ||
0, | ||
18, | ||
0, | ||
"IMAGE" | ||
], | ||
[ | ||
37, | ||
18, | ||
0, | ||
24, | ||
0, | ||
"IMAGE" | ||
], | ||
[ | ||
38, | ||
25, | ||
0, | ||
18, | ||
1, | ||
"IMAGE" | ||
] | ||
], | ||
"groups": [], | ||
"config": {}, | ||
"extra": {}, | ||
"version": 0.4 | ||
} |
Oops, something went wrong.