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
53864bfe
Commit
53864bfe
authored
Aug 24, 2022
by
kurumuz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
limits
parent
5a7f99ce
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
10 deletions
+32
-10
client.py
client.py
+18
-9
hydra_node/models.py
hydra_node/models.py
+1
-1
hydra_node/sanitize.py
hydra_node/sanitize.py
+13
-0
No files found.
client.py
View file @
53864bfe
import
requests
import
json
import
base64
from
PIL
import
Image
import
io
#server hosts on 0.0.0.0
IP_ADDR
=
'0.0.0.0'
PORT
=
'4315'
masks
=
[
{
"seed"
:
811708258
,
"mask"
:
"iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAAAXNSR0IArs4c6QAAAKtJREFUeF7t2LENxDAMA0Br/6GVCf4rNQQvAxiBYPEIz+7uK/7GANwAKyADijPwCUEKUIACFKBA8QR+MjgzryEf9QA9oOGe/8k4K2AFrIAqrAoXF0EPIhjEIAYxiEEMFk8AgxjEIAZjGbx4uY4OwfoBXOgdfQMM4GACboAipAgpQrFF6CADvQpTgAIUoAAFLjhJPYMCFKAABSiQmuAX/00BClCAAhS4SNPUMz4jPAhQiCYcNQAAAABJRU5ErkJggg=="
}
]
payload
=
{
'prompt'
:
'
Hello World
'
,
'prompt'
:
'
test
'
,
"width"
:
512
,
"height"
:
512
,
"scale"
:
12
,
...
...
@@ -15,13 +25,12 @@ payload = {
"n_samples"
:
1
,
"strength"
:
0.7
,
"noise"
:
0.6
,
"masks"
:
[
{
"seed"
:
2023444088
,
"mask"
:
"iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAAAXNSR0IArs4c6QAAAKtJREFUeF7t2LENxDAMA0Br/6GVCf4rNQQvAxiBYPEIz+7uK/7GANwAKyADijPwCUEKUIACFKBA8QR+MjgzryEf9QA9oOGe/8k4K2AFrIAqrAoXF0EPIhjEIAYxiEEMFk8AgxjEIAZjGbx4uY4OwfoBXOgdfQMM4GACboAipAgpQrFF6CADvQpTgAIUoAAFLjhJPYMCFKAABSiQmuAX/00BClCAAhS4SNPUMz4jPAhQiCYcNQAAAABJRU5ErkJggg=="
}
]
"masks"
:
None
}
response
=
requests
.
post
(
'http://'
+
IP_ADDR
+
':'
+
PORT
+
'/generate-stream'
,
json
=
payload
)
print
(
response
.
text
)
\ No newline at end of file
response
=
requests
.
post
(
'http://'
+
IP_ADDR
+
':'
+
PORT
+
'/generate'
,
json
=
payload
)
response
=
response
.
json
()
response
=
response
[
'output'
][
0
]
response
=
base64
.
b64decode
(
response
)
response
=
Image
.
open
(
io
.
BytesIO
(
response
))
response
.
save
(
"test1.png"
)
\ No newline at end of file
hydra_node/models.py
View file @
53864bfe
...
...
@@ -283,7 +283,7 @@ class StableDiffusionModel(nn.Module):
# convert RGB or grayscale image into 4-channel
mask
=
mask
[
0
]
.
unsqueeze
(
0
)
mask
=
torch
.
repeat_interleave
(
mask
,
request
.
latent_channels
,
dim
=
0
)
mask
=
(
mask
>
0.5
)
.
float
()
mask
=
(
mask
<
0.5
)
.
float
()
# interpolate start noise
noise_x
=
(
noise_x
*
(
1
-
mask
))
+
(
sample_start_noise_special
(
mask_seed
+
seed_offset
,
request
,
self
.
device
)
*
mask
)
...
...
hydra_node/sanitize.py
View file @
53864bfe
...
...
@@ -61,6 +61,19 @@ def closest_multiple(num, mult):
return
floor
if
(
num_int
-
floor
)
<
(
ceil
-
num_int
)
else
ceil
def
sanitize_stable_diffusion
(
request
,
config
):
if
request
.
steps
>
50
:
return
False
,
"steps must be smaller than 50"
pixels
=
request
.
height
*
request
.
width
if
(
pixels
>
1024
*
512
and
pixels
<=
1024
*
1204
)
and
request
.
n_samples
>
1
:
return
False
,
"n_samples must be 1 or smaller at this resolution"
if
(
pixels
>
512
*
512
and
pixels
<=
1024
*
512
)
and
request
.
n_samples
>
2
:
return
False
,
"n_samples must be 2 or smaller this resolution"
if
(
pixels
>
256
*
256
and
pixels
<=
512
*
512
)
and
request
.
n_samples
>
4
:
return
False
,
"n_samples must be 4 or smaller at this resolution"
if
request
.
width
*
request
.
height
==
0
:
return
False
,
"width and height must be non-zero"
...
...
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