wolverinn
commited on
Commit
•
27ed9e0
1
Parent(s):
31f2f07
fix lightning download directory
Browse files- README.md +1 -1
- app.py +7 -29
- handler.py +3 -2
- play.py +2 -1
- predict.py +3 -2
README.md
CHANGED
@@ -11,7 +11,7 @@ consider deploy on:
|
|
11 |
|-|-|-|-|
|
12 |
|huggingface|fast:20s|high:$0.6/hr (without autoscaling)|easy:git push|
|
13 |
|replicate|fast if used frequently: 30s, slow if needs initialization: 5min|low: $0.02 per generation|difficult: build image and upload|
|
14 |
-
|lightning.ai|fast with app running: 20s, slow if idle: XXs|low: free $30 per month,
|
15 |
|
16 |
# platform deploy options
|
17 |
## huggingface
|
|
|
11 |
|-|-|-|-|
|
12 |
|huggingface|fast:20s|high:$0.6/hr (without autoscaling)|easy:git push|
|
13 |
|replicate|fast if used frequently: 30s, slow if needs initialization: 5min|low: $0.02 per generation|difficult: build image and upload|
|
14 |
+
|lightning.ai|fast with app running: 20s, slow if idle: XXs|low: free $30 per month, $0.18 per init, $0.02 per run|easy: one command|
|
15 |
|
16 |
# platform deploy options
|
17 |
## huggingface
|
app.py
CHANGED
@@ -18,14 +18,14 @@ class _DefaultInputData(BaseModel):
|
|
18 |
prompt: str
|
19 |
|
20 |
class _DefaultOutputData(BaseModel):
|
21 |
-
|
22 |
parameters: str
|
23 |
|
24 |
|
25 |
@dataclass
|
26 |
class CustomBuildConfig(BuildConfig):
|
27 |
def build_commands(self):
|
28 |
-
dir_path =
|
29 |
model_path = os.path.join(dir_path, "models/Stable-diffusion")
|
30 |
model_url = "https://huggingface.co/Hardy01/chill_watcher/resolve/main/models/Stable-diffusion/chilloutmix_NiPrunedFp32Fix.safetensors"
|
31 |
download_cmd = "wget -P {} {}".format(str(model_path), model_url)
|
@@ -73,8 +73,9 @@ class PyTorchServer(PythonServer):
|
|
73 |
from modules import shared
|
74 |
from modules.processing import StableDiffusionProcessingTxt2Img, process_images
|
75 |
args = {
|
76 |
-
|
77 |
-
"
|
|
|
78 |
"prompt": "lora:koreanDollLikeness_v15:0.66, best quality, ultra high res, (photorealistic:1.4), 1girl, beige sweater, black choker, smile, laughing, bare shoulders, solo focus, ((full body), (brown hair:1), looking at viewer",
|
79 |
"negative_prompt": "paintings, sketches, (worst quality:2), (low quality:2), (normal quality:2), lowres, normal quality, ((monochrome)), ((grayscale)), skin spots, acnes, skin blemishes, age spot, glans, (ugly:1.331), (duplicate:1.331), (morbid:1.21), (mutilated:1.21), (tranny:1.331), mutated hands, (poorly drawn hands:1.331), blurry, 3hands,4fingers,3arms, bad anatomy, missing fingers, extra digit, fewer digits, cropped, jpeg artifacts,poorly drawn face,mutation,deformed",
|
80 |
"sampler_name": "DPM++ SDE Karras",
|
@@ -93,7 +94,7 @@ class PyTorchServer(PythonServer):
|
|
93 |
processed = process_images(p)
|
94 |
single_image_b64 = encode_pil_to_base64(processed.images[0]).decode('utf-8')
|
95 |
return {
|
96 |
-
"
|
97 |
"parameters": processed.images[0].info.get('parameters', ""),
|
98 |
}
|
99 |
|
@@ -101,29 +102,6 @@ class PyTorchServer(PythonServer):
|
|
101 |
component = PyTorchServer(
|
102 |
cloud_compute=L.CloudCompute('gpu', disk_size=20, idle_timeout=30)
|
103 |
)
|
|
|
104 |
app = L.LightningApp(component)
|
105 |
|
106 |
-
# class Flow(L.LightningFlow):
|
107 |
-
# # 1. Define the state
|
108 |
-
# def __init__(self):
|
109 |
-
# self.cloud_build_config = CustomBuildConfig()
|
110 |
-
# super().__init__()
|
111 |
-
# self.component = PyTorchServer(
|
112 |
-
# input_type=Text, output_type=Text, cloud_compute=L.CloudCompute('gpu', disk_size=20, idle_timeout=30)
|
113 |
-
# )
|
114 |
-
|
115 |
-
# # 2. Optional, but used to validate names
|
116 |
-
# def run(self):
|
117 |
-
# self.component.run()
|
118 |
-
|
119 |
-
# # 3. Method executed when a request is received.
|
120 |
-
# def handle_post(self, prompt: str):
|
121 |
-
# return f'The name {name} was registered'
|
122 |
-
|
123 |
-
# # 4. Defines this Component's Restful API. You can have several routes.
|
124 |
-
# def configure_api(self):
|
125 |
-
# return [Post(route="/name", method=self.handle_post)]
|
126 |
-
|
127 |
-
|
128 |
-
# app = L.LightningApp(Flow())
|
129 |
-
|
|
|
18 |
prompt: str
|
19 |
|
20 |
class _DefaultOutputData(BaseModel):
|
21 |
+
img_data: str
|
22 |
parameters: str
|
23 |
|
24 |
|
25 |
@dataclass
|
26 |
class CustomBuildConfig(BuildConfig):
|
27 |
def build_commands(self):
|
28 |
+
dir_path = "/content/"
|
29 |
model_path = os.path.join(dir_path, "models/Stable-diffusion")
|
30 |
model_url = "https://huggingface.co/Hardy01/chill_watcher/resolve/main/models/Stable-diffusion/chilloutmix_NiPrunedFp32Fix.safetensors"
|
31 |
download_cmd = "wget -P {} {}".format(str(model_path), model_url)
|
|
|
73 |
from modules import shared
|
74 |
from modules.processing import StableDiffusionProcessingTxt2Img, process_images
|
75 |
args = {
|
76 |
+
"do_not_save_samples": True,
|
77 |
+
"do_not_save_grid": True,
|
78 |
+
"outpath_samples": "/content/desktop",
|
79 |
"prompt": "lora:koreanDollLikeness_v15:0.66, best quality, ultra high res, (photorealistic:1.4), 1girl, beige sweater, black choker, smile, laughing, bare shoulders, solo focus, ((full body), (brown hair:1), looking at viewer",
|
80 |
"negative_prompt": "paintings, sketches, (worst quality:2), (low quality:2), (normal quality:2), lowres, normal quality, ((monochrome)), ((grayscale)), skin spots, acnes, skin blemishes, age spot, glans, (ugly:1.331), (duplicate:1.331), (morbid:1.21), (mutilated:1.21), (tranny:1.331), mutated hands, (poorly drawn hands:1.331), blurry, 3hands,4fingers,3arms, bad anatomy, missing fingers, extra digit, fewer digits, cropped, jpeg artifacts,poorly drawn face,mutation,deformed",
|
81 |
"sampler_name": "DPM++ SDE Karras",
|
|
|
94 |
processed = process_images(p)
|
95 |
single_image_b64 = encode_pil_to_base64(processed.images[0]).decode('utf-8')
|
96 |
return {
|
97 |
+
"img_data": single_image_b64,
|
98 |
"parameters": processed.images[0].info.get('parameters', ""),
|
99 |
}
|
100 |
|
|
|
102 |
component = PyTorchServer(
|
103 |
cloud_compute=L.CloudCompute('gpu', disk_size=20, idle_timeout=30)
|
104 |
)
|
105 |
+
# lightning run app app.py --cloud
|
106 |
app = L.LightningApp(component)
|
107 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
handler.py
CHANGED
@@ -143,8 +143,9 @@ class EndpointHandler():
|
|
143 |
A :obj:`list` | `dict`: will be serialized and returned
|
144 |
"""
|
145 |
args = {
|
146 |
-
|
147 |
-
"
|
|
|
148 |
"prompt": "lora:koreanDollLikeness_v15:0.66, best quality, ultra high res, (photorealistic:1.4), 1girl, beige sweater, black choker, smile, laughing, bare shoulders, solo focus, ((full body), (brown hair:1), looking at viewer",
|
149 |
"negative_prompt": "paintings, sketches, (worst quality:2), (low quality:2), (normal quality:2), lowres, normal quality, ((monochrome)), ((grayscale)), skin spots, acnes, skin blemishes, age spot, glans, (ugly:1.331), (duplicate:1.331), (morbid:1.21), (mutilated:1.21), (tranny:1.331), mutated hands, (poorly drawn hands:1.331), blurry, 3hands,4fingers,3arms, bad anatomy, missing fingers, extra digit, fewer digits, cropped, jpeg artifacts,poorly drawn face,mutation,deformed",
|
150 |
"sampler_name": "DPM++ SDE Karras",
|
|
|
143 |
A :obj:`list` | `dict`: will be serialized and returned
|
144 |
"""
|
145 |
args = {
|
146 |
+
"do_not_save_samples": True,
|
147 |
+
"do_not_save_grid": True,
|
148 |
+
"outpath_samples": "./output",
|
149 |
"prompt": "lora:koreanDollLikeness_v15:0.66, best quality, ultra high res, (photorealistic:1.4), 1girl, beige sweater, black choker, smile, laughing, bare shoulders, solo focus, ((full body), (brown hair:1), looking at viewer",
|
150 |
"negative_prompt": "paintings, sketches, (worst quality:2), (low quality:2), (normal quality:2), lowres, normal quality, ((monochrome)), ((grayscale)), skin spots, acnes, skin blemishes, age spot, glans, (ugly:1.331), (duplicate:1.331), (morbid:1.21), (mutilated:1.21), (tranny:1.331), mutated hands, (poorly drawn hands:1.331), blurry, 3hands,4fingers,3arms, bad anatomy, missing fingers, extra digit, fewer digits, cropped, jpeg artifacts,poorly drawn face,mutation,deformed",
|
151 |
"sampler_name": "DPM++ SDE Karras",
|
play.py
CHANGED
@@ -12,7 +12,8 @@ def lightning():
|
|
12 |
"prompt": "extremely detailed CG unity 8k wallpaper, masterpiece, best quality, ultra-detailed, best illustration, best shadow, photorealistic:1.4, 1 gorgeous girls,oversize pink_hoodie,under eiffel tower,grey_hair:1.1, collarbone,puffy breasts:1.5,full body shot,shiny eyes,enjoyable expression,evil smile,slim legs,narrow waist,detailed face, looking at viewer,looking back,gorgeous skin,short curly hair,kneeling,puffy ass up,climbing,lying,rosy pussy,nsfw,insert left_hand into pussy",
|
13 |
}
|
14 |
resp = requests.post(url, json=form)
|
15 |
-
|
|
|
16 |
print("time cost(ms): ", int(time.time())*1e3-start*1e3)
|
17 |
|
18 |
|
|
|
12 |
"prompt": "extremely detailed CG unity 8k wallpaper, masterpiece, best quality, ultra-detailed, best illustration, best shadow, photorealistic:1.4, 1 gorgeous girls,oversize pink_hoodie,under eiffel tower,grey_hair:1.1, collarbone,puffy breasts:1.5,full body shot,shiny eyes,enjoyable expression,evil smile,slim legs,narrow waist,detailed face, looking at viewer,looking back,gorgeous skin,short curly hair,kneeling,puffy ass up,climbing,lying,rosy pussy,nsfw,insert left_hand into pussy",
|
13 |
}
|
14 |
resp = requests.post(url, json=form)
|
15 |
+
resp_data = json.loads(resp.content)
|
16 |
+
print(resp.status_code, '\n', resp_data)
|
17 |
print("time cost(ms): ", int(time.time())*1e3-start*1e3)
|
18 |
|
19 |
|
predict.py
CHANGED
@@ -93,8 +93,9 @@ class Predictor(BasePredictor):
|
|
93 |
) -> Dict[str, Any]:
|
94 |
"""Run a single prediction on the model"""
|
95 |
args = {
|
96 |
-
|
97 |
-
"
|
|
|
98 |
"prompt": "lora:koreanDollLikeness_v15:0.66, best quality, ultra high res, (photorealistic:1.4), 1girl, beige sweater, black choker, smile, laughing, bare shoulders, solo focus, ((full body), (brown hair:1), looking at viewer",
|
99 |
"negative_prompt": "paintings, sketches, (worst quality:2), (low quality:2), (normal quality:2), lowres, normal quality, ((monochrome)), ((grayscale)), skin spots, acnes, skin blemishes, age spot, glans, (ugly:1.331), (duplicate:1.331), (morbid:1.21), (mutilated:1.21), (tranny:1.331), mutated hands, (poorly drawn hands:1.331), blurry, 3hands,4fingers,3arms, bad anatomy, missing fingers, extra digit, fewer digits, cropped, jpeg artifacts,poorly drawn face,mutation,deformed",
|
100 |
"sampler_name": "DPM++ SDE Karras",
|
|
|
93 |
) -> Dict[str, Any]:
|
94 |
"""Run a single prediction on the model"""
|
95 |
args = {
|
96 |
+
"do_not_save_samples": True,
|
97 |
+
"do_not_save_grid": True,
|
98 |
+
"outpath_samples": "./output",
|
99 |
"prompt": "lora:koreanDollLikeness_v15:0.66, best quality, ultra high res, (photorealistic:1.4), 1girl, beige sweater, black choker, smile, laughing, bare shoulders, solo focus, ((full body), (brown hair:1), looking at viewer",
|
100 |
"negative_prompt": "paintings, sketches, (worst quality:2), (low quality:2), (normal quality:2), lowres, normal quality, ((monochrome)), ((grayscale)), skin spots, acnes, skin blemishes, age spot, glans, (ugly:1.331), (duplicate:1.331), (morbid:1.21), (mutilated:1.21), (tranny:1.331), mutated hands, (poorly drawn hands:1.331), blurry, 3hands,4fingers,3arms, bad anatomy, missing fingers, extra digit, fewer digits, cropped, jpeg artifacts,poorly drawn face,mutation,deformed",
|
101 |
"sampler_name": "DPM++ SDE Karras",
|