Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
H
Hydra Node Http
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
novelai-storage
Hydra Node Http
Commits
76f08949
Commit
76f08949
authored
Jul 30, 2022
by
novelailab
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
encode as jpeg with simplejpeg
parent
899da5fe
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
3 deletions
+12
-3
Dockerfile
Dockerfile
+1
-0
hydra_node/models.py
hydra_node/models.py
+0
-3
main.py
main.py
+11
-0
No files found.
Dockerfile
View file @
76f08949
...
@@ -20,6 +20,7 @@ RUN git clone https://github.com/NovelAI/stable-diffusion
...
@@ -20,6 +20,7 @@ RUN git clone https://github.com/NovelAI/stable-diffusion
RUN
pip3
install
-e
stable-diffusion/.
RUN
pip3
install
-e
stable-diffusion/.
RUN
pip3
install
pytorch_lightning
RUN
pip3
install
pytorch_lightning
RUN
pip3
install
-e
git+https://github.com/CompVis/taming-transformers.git@master#egg
=
taming-transformers
RUN
pip3
install
-e
git+https://github.com/CompVis/taming-transformers.git@master#egg
=
taming-transformers
RUN
pip3
install
simplejpeg
#Open ports
#Open ports
EXPOSE
8080
EXPOSE
8080
...
...
hydra_node/models.py
View file @
76f08949
...
@@ -122,9 +122,6 @@ class StableDiffusionModel(nn.Module):
...
@@ -122,9 +122,6 @@ class StableDiffusionModel(nn.Module):
images
=
[]
images
=
[]
for
x_sample
in
x_samples_ddim
:
for
x_sample
in
x_samples_ddim
:
x_sample
=
255.
*
rearrange
(
x_sample
.
cpu
()
.
numpy
(),
'c h w -> h w c'
)
x_sample
=
255.
*
rearrange
(
x_sample
.
cpu
()
.
numpy
(),
'c h w -> h w c'
)
x_sample
=
x_sample
.
tobytes
()
#get base64 of x_sample
x_sample
=
str
(
base64
.
b64encode
(
x_sample
))
images
.
append
(
x_sample
)
images
.
append
(
x_sample
)
return
images
return
images
\ No newline at end of file
main.py
View file @
76f08949
...
@@ -14,6 +14,8 @@ import time
...
@@ -14,6 +14,8 @@ import time
import
gc
import
gc
import
os
import
os
import
signal
import
signal
import
simplejpeg
import
base64
#Initialize model and config
#Initialize model and config
model
,
config
=
init_config_model
()
model
,
config
=
init_config_model
()
...
@@ -72,6 +74,15 @@ def generate(request: GenerationRequest):
...
@@ -72,6 +74,15 @@ def generate(request: GenerationRequest):
return
ErrorOutput
(
error
=
output
[
1
])
return
ErrorOutput
(
error
=
output
[
1
])
images
=
model
.
sample
(
request
)
images
=
model
.
sample
(
request
)
for
x
in
range
(
images
):
image
=
simplejpeg
.
encode_jpeg
(
images
[
x
],
quality
=
95
)
image
=
image
.
tobytes
()
#get base64 of image
image
=
str
(
base64
.
b64encode
(
image
))
#remove b' from base64
image
=
image
[
2
:
-
1
]
image
[
x
]
=
image
process_time
=
time
.
perf_counter
()
-
t
process_time
=
time
.
perf_counter
()
-
t
logger
.
info
(
f
"Request took {process_time:0.3f} seconds"
)
logger
.
info
(
f
"Request took {process_time:0.3f} seconds"
)
return
GenerationOutput
(
generation
=
images
)
return
GenerationOutput
(
generation
=
images
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment