-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnode.py
More file actions
44 lines (38 loc) · 1.38 KB
/
node.py
File metadata and controls
44 lines (38 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import requests
import folder_paths
import os
import time
class LoraUploaderUnit:
@classmethod
def INPUT_TYPES(cls):
return {
'required': {
'lora':(folder_paths.get_filename_list("loras"), ) ,
'remote_server':('STRING', {'default': 'http://localhost:8000'})
}
}
RETURN_TYPES = ("STRING",)
RETURN_NAMES = ("message",)
FUNCTION = 'run'
CATEGORY = 'cfy_uploader'
def run(self,lora,remote_server):
start_time = time.time()
print(f"The lora is {lora}")
print(f"The remote server is {remote_server}")
lora_file = folder_paths.get_full_path("loras", lora)
lora_size = os.path.getsize(lora_file)
lora_size = lora_size / 1024 / 1024
print(f"The lora size is {lora_size:.2f} MB")
files = {'file': open(lora_file, 'rb')}
response = requests.post(remote_server, files=files)
if response.status_code == 200:
message = f"Lora {lora} uploaded successfully , size: {lora_size:.2f} MB , time cost: {time.time() - start_time:.2f} s"
else:
message = f"Failed to upload lora, status code: {response.status_code} , response text: {response.text}"
return (message,)
NODE_CLASS_MAPPINGS = {
"LoraUploaderUnit": LoraUploaderUnit,
}
NODE_DISPLAY_NAME_MAPPINGS = {
"LoraUploaderUnit": "LoraUnit",
}