Skip to content

Commit

Permalink
dimension options
Browse files Browse the repository at this point in the history
  • Loading branch information
chaojie committed Jan 15, 2024
1 parent 0dec6e5 commit 6f9c5f6
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 160 deletions.
Binary file modified assets/base_wf.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 8 additions & 7 deletions nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,7 @@ def INPUT_TYPES(cls):
return {
"required": {
"ckpt_name": (folder_paths.get_filename_list("checkpoints"), {"default": "drag_nuwa_svd.pth"}),
"height": ("INT", {"default": 320}),
"width": ("INT", {"default": 576}),
"dimension": (["576x320","512x512","320x576"], {"default": "576x320"}),
"model_length": ("INT", {"default": 14}),
}
}
Expand All @@ -214,7 +213,9 @@ def INPUT_TYPES(cls):
FUNCTION = "load_dragnuwa"
CATEGORY = "DragNUWA"

def load_dragnuwa(self, ckpt_name, height, width, model_length):
def load_dragnuwa(self, ckpt_name, dimension, model_length):
width=int(dimension.split('x')[0])
height=int(dimension.split('x')[1])
comfy_path = os.path.dirname(folder_paths.__file__)
ckpt_path = folder_paths.get_full_path("checkpoints", ckpt_name)
current_path = os.path.abspath(os.path.dirname(__file__))
Expand Down Expand Up @@ -312,11 +313,11 @@ def split_tracking_points(self, pose_kps, split_index, height, width, last_pose_
else:
break

if len(traj)>0:
trajs.append(traj)
if len(traj)>0:
trajs.append(traj)


return (json.dumps(trajs),)
return (json.dumps(trajs),)

class GetFirstImage:
@classmethod
Expand Down
43 changes: 36 additions & 7 deletions tools/draw.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
</head>

<body>
<select id="dimension" onchange="changeDimension()">
<option>576x320</option>
<option>320x576</option>
<option>512x512</option>
</select>
<input type="file" id="inputFile" accept="image/*" />
<button type="button" onclick="newline()">new line</button><br/>
Click on canvas to draw traj<br/>
Expand Down Expand Up @@ -55,6 +60,28 @@
lines.push(userDrawnPixels);
}

var inited=false;

function changeDimension(){
var x=0,y=0,w=imageNode.width,h=imageNode.height;
dimension=document.getElementById("dimension").value.split('x');
canvas.width=dimension[0];
canvas.height=dimension[1];
//ctx.drawImage(imageNode, x, y, w, h, 0, 0, w, h);
if(imageNode.width/imageNode.height>canvas.width/canvas.height){
y=0;
h=imageNode.height;
w=imageNode.height*canvas.width/canvas.height;
x=(imageNode.width-w)/2;
}else{
x=0;
w=imageNode.width;
h=imageNode.width*canvas.height/canvas.width;
y=(imageNode.height-h)/2;
}
ctx.drawImage(imageNode, x, y, w, h, 0, 0, canvas.width, canvas.height);
}

// Set-up the canvas and add our event handlers after the page has loaded
function init() {
// Get the specific canvas element from the HTML document
Expand Down Expand Up @@ -89,22 +116,24 @@
reader.onload = function (e) {
imageNode.src = e.target.result;
imageNode.onload = function () {
inited=true;
var x=0,y=0,w=this.width,h=this.height;
canvas.width=w;
canvas.height=h;
ctx.drawImage(imageNode, x, y, w, h, 0, 0, w, h);
/*if(this.width/this.height>576/320){
dimension=document.getElementById("dimension").value.split('x');
canvas.width=dimension[0];
canvas.height=dimension[1];
//ctx.drawImage(imageNode, x, y, w, h, 0, 0, w, h);
if(this.width/this.height>canvas.width/canvas.height){
y=0;
h=this.height;
w=this.height*576/320;
w=this.height*canvas.width/canvas.height;
x=(this.width-w)/2;
}else{
x=0;
w=this.width;
h=this.width*320/576;
h=this.width*canvas.height/canvas.width;
y=(this.height-h)/2;
}
ctx.drawImage(imageNode, x, y, w, h, 0, 0, 576, 320);*/
ctx.drawImage(imageNode, x, y, w, h, 0, 0, canvas.width, canvas.height);

};
};
Expand Down
Loading

0 comments on commit 6f9c5f6

Please sign in to comment.