6
6
from bpy .types import Operator
7
7
from .utils import ensure_gradio_installed , install_gradio
8
8
9
+ # Clients API config
10
+ client_config = {
11
+ "shap_e" : "hysts/Shap-E" ,
12
+ "sdxl" : "hysts/SDXL" ,
13
+ "one_2_3_45" : "https://one-2-3-45-one-2-3-45.hf.space/" ,
14
+ "dreamgaussian" : "https://jiawei011-dreamgaussian.hf.space/" ,
15
+ "instantmesh" : "TencentARC/InstantMesh" ,
16
+ "triposr" : "stabilityai/TripoSR"
17
+ }
18
+
9
19
class InstallDependenciesOperator (Operator ):
10
20
bl_idname = "wm.install_dependencies"
11
21
bl_label = "Install Dependencies"
@@ -67,6 +77,9 @@ def run_pipeline(self, autosculptor_props):
67
77
image_height = autosculptor_props .image_height
68
78
api_key = autosculptor_props .api_key
69
79
80
+ if api_key == "" :
81
+ api_key = None
82
+
70
83
for _ in range (batch_count ):
71
84
# Get seed for generation
72
85
seed = autosculptor_props .seed
@@ -140,7 +153,8 @@ def generate_model(self, prompt, seed, guidance_scale, num_inference_steps, mode
140
153
141
154
def generate_shape_e_model (self , api_key , prompt , seed , guidance_scale , num_inference_steps ):
142
155
from gradio_client import Client
143
- client = Client ("hysts/Shap-E" , hf_token = api_key )
156
+
157
+ client = Client (client_config ["shap_e" ], hf_token = api_key ) if api_key else Client (client_config ["shap_e" ])
144
158
result = client .predict (
145
159
prompt = prompt ,
146
160
seed = seed ,
@@ -152,7 +166,7 @@ def generate_shape_e_model(self, api_key, prompt, seed, guidance_scale, num_infe
152
166
153
167
def generate_sdxl_shape_e_model (self , api_key , prompt , seed , guidance_scale , num_inference_steps , image_width , image_height ):
154
168
from gradio_client import Client , handle_file
155
- client1 = Client ("hysts/SDXL" , hf_token = api_key )
169
+ client1 = Client (client_config [ "sdxl" ] , hf_token = api_key ) if api_key else Client ( client_config [ "sdxl" ] )
156
170
image = client1 .predict (
157
171
prompt = prompt ,
158
172
negative_prompt = "" ,
@@ -167,13 +181,13 @@ def generate_sdxl_shape_e_model(self, api_key, prompt, seed, guidance_scale, num
167
181
)
168
182
image_path = image
169
183
170
- client2 = Client ("https://one-2-3-45-one-2-3-45.hf.space/" , hf_token = api_key )
184
+ client2 = Client (client_config [ "one_2_3_45" ] , hf_token = api_key ) if api_key else Client ( client_config [ "one_2_3_45" ] )
171
185
segmented_img_filepath = client2 .predict (
172
186
image_path ,
173
187
api_name = "/preprocess"
174
- )
188
+ )
175
189
176
- client3 = Client ("hysts/Shap-E" , hf_token = api_key )
190
+ client3 = Client (client_config [ "shap_e" ] , hf_token = api_key ) if api_key else Client ( client_config [ "shap_e" ] )
177
191
result = client3 .predict (
178
192
image = handle_file (segmented_img_filepath ),
179
193
seed = seed ,
@@ -185,7 +199,7 @@ def generate_sdxl_shape_e_model(self, api_key, prompt, seed, guidance_scale, num
185
199
186
200
def generate_sdxl_dreamgaussian_model (self , api_key , prompt , seed , guidance_scale , num_inference_steps , image_width , image_height ):
187
201
from gradio_client import Client , handle_file
188
- client1 = Client ("hysts/SDXL" , hf_token = api_key )
202
+ client1 = Client (client_config [ "sdxl" ] , hf_token = api_key ) if api_key else Client ( client_config [ "sdxl" ] )
189
203
image = client1 .predict (
190
204
prompt = prompt ,
191
205
negative_prompt = "" ,
@@ -200,17 +214,17 @@ def generate_sdxl_dreamgaussian_model(self, api_key, prompt, seed, guidance_scal
200
214
)
201
215
image_path = image
202
216
203
- client2 = Client ("https://one-2-3-45-one-2-3-45.hf.space/" , hf_token = api_key )
217
+ client2 = Client (client_config [ "one_2_3_45" ] , hf_token = api_key ) if api_key else Client ( client_config [ "one_2_3_45" ] )
204
218
elevation_angle_deg = client2 .predict (
205
219
image_path ,
206
220
True ,
207
221
api_name = "/estimate_elevation"
208
- )
222
+ )
209
223
210
224
if elevation_angle_deg < - 90 or elevation_angle_deg > 90 :
211
225
elevation_angle_deg = 0
212
226
213
- client3 = Client ("https://jiawei011- dreamgaussian.hf.space/" , hf_token = api_key )
227
+ client3 = Client (client_config [ " dreamgaussian" ] , hf_token = api_key ) if api_key else Client ( client_config [ "dreamgaussian" ] )
214
228
result = client3 .predict (
215
229
image_path ,
216
230
True ,
@@ -221,7 +235,7 @@ def generate_sdxl_dreamgaussian_model(self, api_key, prompt, seed, guidance_scal
221
235
222
236
def generate_sdxl_instantmesh_model (self , api_key , prompt , seed , guidance_scale , num_inference_steps , image_width , image_height ):
223
237
from gradio_client import Client , handle_file
224
- client1 = Client ("hysts/SDXL" , hf_token = api_key )
238
+ client1 = Client (client_config [ "sdxl" ] , hf_token = api_key ) if api_key else Client ( client_config [ "sdxl" ] )
225
239
image = client1 .predict (
226
240
prompt = prompt ,
227
241
negative_prompt = "" ,
@@ -236,7 +250,7 @@ def generate_sdxl_instantmesh_model(self, api_key, prompt, seed, guidance_scale,
236
250
)
237
251
image_path = image
238
252
239
- client2 = Client ("TencentARC/InstantMesh" , hf_token = api_key )
253
+ client2 = Client (client_config [ "instantmesh" ] , hf_token = api_key ) if api_key else Client ( client_config [ "instantmesh" ] )
240
254
processed_image = client2 .predict (
241
255
input_image = handle_file (image_path ),
242
256
do_remove_background = True ,
@@ -257,7 +271,7 @@ def generate_sdxl_instantmesh_model(self, api_key, prompt, seed, guidance_scale,
257
271
258
272
def generate_sdxl_triposr_model (self , api_key , prompt , seed , guidance_scale , num_inference_steps , image_width , image_height ):
259
273
from gradio_client import Client , handle_file
260
- client1 = Client ("hysts/SDXL" , hf_token = api_key )
274
+ client1 = Client (client_config [ "sdxl" ] , hf_token = api_key ) if api_key else Client ( client_config [ "sdxl" ] )
261
275
image = client1 .predict (
262
276
prompt = prompt ,
263
277
negative_prompt = "" ,
@@ -272,7 +286,7 @@ def generate_sdxl_triposr_model(self, api_key, prompt, seed, guidance_scale, num
272
286
)
273
287
image_path = image
274
288
275
- client2 = Client ("stabilityai/TripoSR" , hf_token = api_key )
289
+ client2 = Client (client_config [ "triposr" ] , hf_token = api_key ) if api_key else Client ( client_config [ "triposr" ] )
276
290
processed_image = client2 .predict (
277
291
handle_file (image_path ),
278
292
True ,
0 commit comments