Spaces:
Running
on
Zero
Running
on
Zero
ziyuwang98
commited on
Commit
β’
e111eda
1
Parent(s):
9415d4f
zeroGPU OK
Browse files- Rodin.py +2 -4
- app.py +8 -7
- {OpenCLAY/openclay β openclay}/models/__init__.py +0 -0
- {OpenCLAY/openclay β openclay}/models/condition.py +0 -0
- {OpenCLAY/openclay β openclay}/models/ldm.py +0 -0
- {OpenCLAY/openclay β openclay}/models/vae.py +0 -0
- {OpenCLAY/openclay β openclay}/modules/attention.py +0 -0
- {OpenCLAY/openclay β openclay}/modules/control_volume.py +0 -0
- {OpenCLAY/openclay β openclay}/modules/diag_gaussian.py +0 -0
- {OpenCLAY/openclay β openclay}/modules/drop_path.py +0 -0
- {OpenCLAY/openclay β openclay}/modules/embedding.py +0 -0
- {OpenCLAY/openclay β openclay}/modules/transformer.py +0 -0
- {OpenCLAY/openclay β openclay}/pipeline_openclay.py +0 -0
- {OpenCLAY/openclay β openclay}/utils.py +0 -0
Rodin.py
CHANGED
@@ -73,9 +73,8 @@ def crop_image(image, type):
|
|
73 |
new_image.paste(cropped_image, (i * 360, 0))
|
74 |
return new_image
|
75 |
|
76 |
-
# Perform Rodin mesh operation
|
77 |
-
|
78 |
|
|
|
79 |
def rodin_mesh(prompt, group_uuid, settings, images, name, token):
|
80 |
images = [convert_base64_to_binary(img) for img in images]
|
81 |
|
@@ -95,9 +94,8 @@ def rodin_mesh(prompt, group_uuid, settings, images, name, token):
|
|
95 |
response = requests.post(f"{BASE_URL}/task/rodin_mesh", data=m, headers=headers)
|
96 |
return response
|
97 |
|
98 |
-
# Convert base64 to binary since the result from `rodin_preprocess_image` is encoded with base64
|
99 |
-
|
100 |
|
|
|
101 |
def convert_base64_to_binary(base64_string):
|
102 |
if ',' in base64_string:
|
103 |
base64_string = base64_string.split(',')[1]
|
|
|
73 |
new_image.paste(cropped_image, (i * 360, 0))
|
74 |
return new_image
|
75 |
|
|
|
|
|
76 |
|
77 |
+
# Perform Rodin mesh operation
|
78 |
def rodin_mesh(prompt, group_uuid, settings, images, name, token):
|
79 |
images = [convert_base64_to_binary(img) for img in images]
|
80 |
|
|
|
94 |
response = requests.post(f"{BASE_URL}/task/rodin_mesh", data=m, headers=headers)
|
95 |
return response
|
96 |
|
|
|
|
|
97 |
|
98 |
+
# Convert base64 to binary since the result from `rodin_preprocess_image` is encoded with base64
|
99 |
def convert_base64_to_binary(base64_string):
|
100 |
if ',' in base64_string:
|
101 |
base64_string = base64_string.split(',')[1]
|
app.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
-
from
|
2 |
-
from
|
3 |
-
from
|
4 |
from transformers import Dinov2Model, BitImageProcessor, CLIPTextModel, CLIPTokenizer
|
5 |
import trimesh
|
6 |
import cv2
|
@@ -20,7 +20,7 @@ import spaces
|
|
20 |
import re
|
21 |
from gradio_fake3d import Fake3D
|
22 |
from PIL import Image
|
23 |
-
from Rodin import Generator, crop_image, log
|
24 |
from constant import *
|
25 |
|
26 |
generator = Generator(USER, PASSWORD, TOKEN)
|
@@ -58,8 +58,9 @@ def read_image(path, image_processor, image_encoder, size=224):
|
|
58 |
return render, image_embeds_patch
|
59 |
|
60 |
@spaces.GPU
|
61 |
-
def local_inference(block_prompt,
|
62 |
-
|
|
|
63 |
|
64 |
mesh = pipe(
|
65 |
prompt=block_prompt, negative_prompt='fragmentation.',
|
@@ -389,7 +390,7 @@ with gr.Blocks() as demo:
|
|
389 |
queue=True
|
390 |
).success(
|
391 |
fn=local_inference,
|
392 |
-
inputs=[block_prompt,
|
393 |
outputs=[block_3d],
|
394 |
queue=True
|
395 |
).then(
|
|
|
1 |
+
from openclay.pipeline_openclay import OpenClayPipeline
|
2 |
+
from openclay.models import ClayVAE, ClayLDM, ClayConditionNet
|
3 |
+
from openclay.utils import read_image_square
|
4 |
from transformers import Dinov2Model, BitImageProcessor, CLIPTextModel, CLIPTokenizer
|
5 |
import trimesh
|
6 |
import cv2
|
|
|
20 |
import re
|
21 |
from gradio_fake3d import Fake3D
|
22 |
from PIL import Image
|
23 |
+
from Rodin import Generator, crop_image, log, convert_base64_to_binary
|
24 |
from constant import *
|
25 |
|
26 |
generator = Generator(USER, PASSWORD, TOKEN)
|
|
|
58 |
return render, image_embeds_patch
|
59 |
|
60 |
@spaces.GPU
|
61 |
+
def local_inference(block_prompt, cache_image_base64):
|
62 |
+
image = convert_base64_to_binary(cache_image_base64)
|
63 |
+
_, image_embeds_patch = read_image(image, image_processor, image_encoder)
|
64 |
|
65 |
mesh = pipe(
|
66 |
prompt=block_prompt, negative_prompt='fragmentation.',
|
|
|
390 |
queue=True
|
391 |
).success(
|
392 |
fn=local_inference,
|
393 |
+
inputs=[block_prompt, cache_image_base64],
|
394 |
outputs=[block_3d],
|
395 |
queue=True
|
396 |
).then(
|
{OpenCLAY/openclay β openclay}/models/__init__.py
RENAMED
File without changes
|
{OpenCLAY/openclay β openclay}/models/condition.py
RENAMED
File without changes
|
{OpenCLAY/openclay β openclay}/models/ldm.py
RENAMED
File without changes
|
{OpenCLAY/openclay β openclay}/models/vae.py
RENAMED
File without changes
|
{OpenCLAY/openclay β openclay}/modules/attention.py
RENAMED
File without changes
|
{OpenCLAY/openclay β openclay}/modules/control_volume.py
RENAMED
File without changes
|
{OpenCLAY/openclay β openclay}/modules/diag_gaussian.py
RENAMED
File without changes
|
{OpenCLAY/openclay β openclay}/modules/drop_path.py
RENAMED
File without changes
|
{OpenCLAY/openclay β openclay}/modules/embedding.py
RENAMED
File without changes
|
{OpenCLAY/openclay β openclay}/modules/transformer.py
RENAMED
File without changes
|
{OpenCLAY/openclay β openclay}/pipeline_openclay.py
RENAMED
File without changes
|
{OpenCLAY/openclay β openclay}/utils.py
RENAMED
File without changes
|