ClaireOzzz commited on
Commit
a8f64d2
1 Parent(s): 24e70a8

Upload 55 files

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +7 -0
  2. viteGradio/.eslintrc.cjs +20 -0
  3. viteGradio/.gitignore +24 -0
  4. viteGradio/README.md +397 -0
  5. viteGradio/another-page.html +254 -0
  6. viteGradio/dist/index.2cdaf7bc.css +19 -0
  7. viteGradio/dist/index.2cdaf7bc.css.map +1 -0
  8. viteGradio/dist/index.975ef6c8.js +0 -0
  9. viteGradio/dist/index.975ef6c8.js.map +0 -0
  10. viteGradio/dist/index.html +12 -0
  11. viteGradio/dist/roots2_rgbd.c6f8f977.png +3 -0
  12. viteGradio/images/depth.png +0 -0
  13. viteGradio/images/depth1.png +0 -0
  14. viteGradio/images/depth2.png +0 -0
  15. viteGradio/images/depth3.png +0 -0
  16. viteGradio/images/depth4.png +0 -0
  17. viteGradio/images/depth5.png +0 -0
  18. viteGradio/images/depth6.png +0 -0
  19. viteGradio/images/names.json +15 -0
  20. viteGradio/images/result.png +3 -0
  21. viteGradio/images/result1.png +3 -0
  22. viteGradio/images/result2.png +3 -0
  23. viteGradio/images/result3.png +3 -0
  24. viteGradio/images/result4.png +3 -0
  25. viteGradio/images/result5.png +3 -0
  26. viteGradio/images/result6.png +3 -0
  27. viteGradio/index.html +30 -0
  28. viteGradio/package-lock.json +0 -0
  29. viteGradio/package.json +29 -0
  30. viteGradio/public/SUNS.png +0 -0
  31. viteGradio/public/intro2.mp4 +3 -0
  32. viteGradio/public/vite.svg +1 -0
  33. viteGradio/src/3Dviewer.jsx +153 -0
  34. viteGradio/src/App.css +172 -0
  35. viteGradio/src/App.jsx +46 -0
  36. viteGradio/src/Header.jsx +41 -0
  37. viteGradio/src/PromptPage.jsx +35 -0
  38. viteGradio/src/ReviewPage.jsx +19 -0
  39. viteGradio/src/VisualisationPage.jsx +23 -0
  40. viteGradio/src/assets/image (2).png +0 -0
  41. viteGradio/src/assets/input.png +3 -0
  42. viteGradio/src/assets/output.jpg +0 -0
  43. viteGradio/src/assets/react.svg +1 -0
  44. viteGradio/src/assets/roots2_rgbd.png +3 -0
  45. viteGradio/src/assets/shop.jpeg +0 -0
  46. viteGradio/src/assets/shop2.png +0 -0
  47. viteGradio/src/assets/shopd.png +0 -0
  48. viteGradio/src/assets/shopt.jpeg +0 -0
  49. viteGradio/src/components/api.jsx +3 -0
  50. viteGradio/src/components/original.jsx +55 -0
.gitattributes CHANGED
@@ -37,3 +37,10 @@ viteGradio/dist/roots2_rgbd.c6f8f977.png filter=lfs diff=lfs merge=lfs -text
37
  viteGradio/public/intro2.mp4 filter=lfs diff=lfs merge=lfs -text
38
  viteGradio/src/assets/input.png filter=lfs diff=lfs merge=lfs -text
39
  viteGradio/src/assets/roots2_rgbd.png filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
37
  viteGradio/public/intro2.mp4 filter=lfs diff=lfs merge=lfs -text
38
  viteGradio/src/assets/input.png filter=lfs diff=lfs merge=lfs -text
39
  viteGradio/src/assets/roots2_rgbd.png filter=lfs diff=lfs merge=lfs -text
40
+ viteGradio/images/result.png filter=lfs diff=lfs merge=lfs -text
41
+ viteGradio/images/result1.png filter=lfs diff=lfs merge=lfs -text
42
+ viteGradio/images/result2.png filter=lfs diff=lfs merge=lfs -text
43
+ viteGradio/images/result3.png filter=lfs diff=lfs merge=lfs -text
44
+ viteGradio/images/result4.png filter=lfs diff=lfs merge=lfs -text
45
+ viteGradio/images/result5.png filter=lfs diff=lfs merge=lfs -text
46
+ viteGradio/images/result6.png filter=lfs diff=lfs merge=lfs -text
viteGradio/.eslintrc.cjs ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ module.exports = {
2
+ root: true,
3
+ env: { browser: true, es2020: true },
4
+ extends: [
5
+ 'eslint:recommended',
6
+ 'plugin:react/recommended',
7
+ 'plugin:react/jsx-runtime',
8
+ 'plugin:react-hooks/recommended',
9
+ ],
10
+ ignorePatterns: ['dist', '.eslintrc.cjs'],
11
+ parserOptions: { ecmaVersion: 'latest', sourceType: 'module' },
12
+ settings: { react: { version: '18.2' } },
13
+ plugins: ['react-refresh'],
14
+ rules: {
15
+ 'react-refresh/only-export-components': [
16
+ 'warn',
17
+ { allowConstantExport: true },
18
+ ],
19
+ },
20
+ }
viteGradio/.gitignore ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Logs
2
+ logs
3
+ *.log
4
+ npm-debug.log*
5
+ yarn-debug.log*
6
+ yarn-error.log*
7
+ pnpm-debug.log*
8
+ lerna-debug.log*
9
+
10
+ node_modules
11
+ dist
12
+ dist-ssr
13
+ *.local
14
+
15
+ # Editor directories and files
16
+ .vscode/*
17
+ !.vscode/extensions.json
18
+ .idea
19
+ .DS_Store
20
+ *.suo
21
+ *.ntvs*
22
+ *.njsproj
23
+ *.sln
24
+ *.sw?
viteGradio/README.md ADDED
@@ -0,0 +1,397 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from huggingface_hub import login, HfFileSystem, HfApi, ModelCard
3
+ import os
4
+ import spaces
5
+ import random
6
+ import torch
7
+
8
+ is_shared_ui = False
9
+
10
+ hf_token = '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'
11
+ login(token=hf_token)
12
+
13
+ fs = HfFileSystem(token=hf_token)
14
+ api = HfApi()
15
+
16
+ device="cuda" if torch.cuda.is_available() else "cpu"
17
+
18
+ from diffusers import ControlNetModel, StableDiffusionXLControlNetPipeline, AutoencoderKL
19
+ from diffusers.utils import load_image
20
+ from PIL import Image
21
+ import torch
22
+ import numpy as np
23
+ import cv2
24
+
25
+ vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix", torch_dtype=torch.float16)
26
+
27
+ controlnet = ControlNetModel.from_pretrained(
28
+ "diffusers/controlnet-canny-sdxl-1.0",
29
+ torch_dtype=torch.float16
30
+ )
31
+
32
+ def check_use_custom_or_no(value):
33
+ if value is True:
34
+ return gr.update(visible=True)
35
+ else:
36
+ return gr.update(visible=False)
37
+
38
+ def get_files(file_paths):
39
+ last_files = {} # Dictionary to store the last file for each path
40
+
41
+ for file_path in file_paths:
42
+ # Split the file path into directory and file components
43
+ directory, file_name = file_path.rsplit('/', 1)
44
+
45
+ # Update the last file for the current path
46
+ last_files[directory] = file_name
47
+
48
+ # Extract the last files from the dictionary
49
+ result = list(last_files.values())
50
+
51
+ return result
52
+
53
+ def load_model(model_name):
54
+
55
+ if model_name == "":
56
+ gr.Warning("If you want to use a private model, you need to duplicate this space on your personal account.")
57
+ raise gr.Error("You forgot to define Model ID.")
58
+
59
+ # Get instance_prompt a.k.a trigger word
60
+ card = ModelCard.load(model_name)
61
+ repo_data = card.data.to_dict()
62
+ instance_prompt = repo_data.get("instance_prompt")
63
+
64
+ if instance_prompt is not None:
65
+ print(f"Trigger word: {instance_prompt}")
66
+ else:
67
+ instance_prompt = "no trigger word needed"
68
+ print(f"Trigger word: no trigger word needed")
69
+
70
+ # List all ".safetensors" files in repo
71
+ sfts_available_files = fs.glob(f"{model_name}/*safetensors")
72
+ sfts_available_files = get_files(sfts_available_files)
73
+
74
+ if sfts_available_files == []:
75
+ sfts_available_files = ["NO SAFETENSORS FILE"]
76
+
77
+ print(f"Safetensors available: {sfts_available_files}")
78
+
79
+ return model_name, "Model Ready", gr.update(choices=sfts_available_files, value=sfts_available_files[0], visible=True), gr.update(value=instance_prompt, visible=True)
80
+
81
+ def custom_model_changed(model_name, previous_model):
82
+ if model_name == "" and previous_model == "" :
83
+ status_message = ""
84
+ elif model_name != previous_model:
85
+ status_message = "model changed, please reload before any new run"
86
+ else:
87
+ status_message = "model ready"
88
+ return status_message
89
+
90
+ def resize_image(input_path, output_path, target_height):
91
+ # Open the input image
92
+ img = Image.open(input_path)
93
+
94
+ # Calculate the aspect ratio of the original image
95
+ original_width, original_height = img.size
96
+ original_aspect_ratio = original_width / original_height
97
+
98
+ # Calculate the new width while maintaining the aspect ratio and the target height
99
+ new_width = int(target_height * original_aspect_ratio)
100
+
101
+ # Resize the image while maintaining the aspect ratio and fixing the height
102
+ img = img.resize((new_width, target_height), Image.LANCZOS)
103
+
104
+ # Save the resized image
105
+ img.save(output_path)
106
+
107
+ return output_path
108
+
109
+ @spaces.GPU
110
+ def infer(use_custom_model, model_name, weight_name, custom_lora_weight, image_in, prompt, negative_prompt, preprocessor, controlnet_conditioning_scale, guidance_scale, inf_steps, seed, progress=gr.Progress(track_tqdm=True)):
111
+
112
+ pipe = StableDiffusionXLControlNetPipeline.from_pretrained(
113
+ "stabilityai/stable-diffusion-xl-base-1.0",
114
+ controlnet=controlnet,
115
+ vae=vae,
116
+ torch_dtype=torch.float16,
117
+ variant="fp16",
118
+ use_safetensors=True
119
+ )
120
+
121
+ pipe.to(device)
122
+
123
+ prompt = prompt
124
+ negative_prompt = negative_prompt
125
+
126
+ if seed < 0 :
127
+ seed = random.randint(0, 423538377342)
128
+
129
+ generator = torch.Generator(device=device).manual_seed(seed)
130
+
131
+ if image_in == None:
132
+ raise gr.Error("You forgot to upload a source image.")
133
+
134
+ image_in = resize_image(image_in, "resized_input.jpg", 1024)
135
+
136
+ if preprocessor == "canny":
137
+
138
+ image = load_image(image_in)
139
+
140
+ image = np.array(image)
141
+ image = cv2.Canny(image, 100, 200)
142
+ image = image[:, :, None]
143
+ image = np.concatenate([image, image, image], axis=2)
144
+ image = Image.fromarray(image)
145
+
146
+ if use_custom_model:
147
+
148
+ if model_name == "":
149
+ raise gr.Error("you forgot to set a custom model name.")
150
+
151
+ custom_model = model_name
152
+
153
+ # This is where you load your trained weights
154
+ if weight_name == "NO SAFETENSORS FILE":
155
+ pipe.load_lora_weights(
156
+ custom_model,
157
+ low_cpu_mem_usage = True,
158
+ use_auth_token = True
159
+ )
160
+
161
+ else:
162
+ pipe.load_lora_weights(
163
+ custom_model,
164
+ weight_name = weight_name,
165
+ low_cpu_mem_usage = True,
166
+ use_auth_token = True
167
+ )
168
+
169
+ lora_scale=custom_lora_weight
170
+
171
+ images = pipe(
172
+ prompt,
173
+ negative_prompt=negative_prompt,
174
+ image=image,
175
+ controlnet_conditioning_scale=float(controlnet_conditioning_scale),
176
+ guidance_scale = float(guidance_scale),
177
+ num_inference_steps=inf_steps,
178
+ generator=generator,
179
+ cross_attention_kwargs={"scale": lora_scale}
180
+ ).images
181
+ else:
182
+ images = pipe(
183
+ prompt,
184
+ negative_prompt=negative_prompt,
185
+ image=image,
186
+ controlnet_conditioning_scale=float(controlnet_conditioning_scale),
187
+ guidance_scale = float(guidance_scale),
188
+ num_inference_steps=inf_steps,
189
+ generator=generator,
190
+ ).images
191
+
192
+ images[0].save(f"result.png")
193
+
194
+ return f"result.png", seed
195
+
196
+ css="""
197
+ #col-container{
198
+ margin: 0 auto;
199
+ max-width: 720px;
200
+ text-align: left;
201
+ }
202
+ div#warning-duplicate {
203
+ background-color: #ebf5ff;
204
+ padding: 0 10px 5px;
205
+ margin: 20px 0;
206
+ }
207
+ div#warning-duplicate > .gr-prose > h2, div#warning-duplicate > .gr-prose > p {
208
+ color: #0f4592!important;
209
+ }
210
+ div#warning-duplicate strong {
211
+ color: #0f4592;
212
+ }
213
+ p.actions {
214
+ display: flex;
215
+ align-items: center;
216
+ margin: 20px 0;
217
+ }
218
+ div#warning-duplicate .actions a {
219
+ display: inline-block;
220
+ margin-right: 10px;
221
+ }
222
+ button#load_model_btn{
223
+ height: 46px;
224
+ }
225
+ #status_info{
226
+ font-size: 0.9em;
227
+ }
228
+ """
229
+
230
+ theme = gr.themes.Soft(
231
+ primary_hue="teal",
232
+ secondary_hue="gray",
233
+ ).set(
234
+ body_text_color_dark='*neutral_800',
235
+ background_fill_primary_dark='*neutral_50',
236
+ background_fill_secondary_dark='*neutral_50',
237
+ border_color_accent_dark='*primary_300',
238
+ border_color_primary_dark='*neutral_200',
239
+ color_accent_soft_dark='*neutral_50',
240
+ link_text_color_dark='*secondary_600',
241
+ link_text_color_active_dark='*secondary_600',
242
+ link_text_color_hover_dark='*secondary_700',
243
+ link_text_color_visited_dark='*secondary_500',
244
+ code_background_fill_dark='*neutral_100',
245
+ shadow_spread_dark='6px',
246
+ block_background_fill_dark='white',
247
+ block_label_background_fill_dark='*primary_100',
248
+ block_label_text_color_dark='*primary_500',
249
+ block_title_text_color_dark='*primary_500',
250
+ checkbox_background_color_dark='*background_fill_primary',
251
+ checkbox_background_color_selected_dark='*primary_600',
252
+ checkbox_border_color_dark='*neutral_100',
253
+ checkbox_border_color_focus_dark='*primary_500',
254
+ checkbox_border_color_hover_dark='*neutral_300',
255
+ checkbox_border_color_selected_dark='*primary_600',
256
+ checkbox_label_background_fill_selected_dark='*primary_500',
257
+ checkbox_label_text_color_selected_dark='white',
258
+ error_background_fill_dark='#fef2f2',
259
+ error_border_color_dark='#b91c1c',
260
+ error_text_color_dark='#b91c1c',
261
+ error_icon_color_dark='#b91c1c',
262
+ input_background_fill_dark='white',
263
+ input_background_fill_focus_dark='*secondary_500',
264
+ input_border_color_dark='*neutral_50',
265
+ input_border_color_focus_dark='*secondary_300',
266
+ input_placeholder_color_dark='*neutral_400',
267
+ slider_color_dark='*primary_500',
268
+ stat_background_fill_dark='*primary_300',
269
+ table_border_color_dark='*neutral_300',
270
+ table_even_background_fill_dark='white',
271
+ table_odd_background_fill_dark='*neutral_50',
272
+ button_primary_background_fill_dark='*primary_500',
273
+ button_primary_background_fill_hover_dark='*primary_400',
274
+ button_primary_border_color_dark='*primary_00',
275
+ button_secondary_background_fill_dark='whiite',
276
+ button_secondary_background_fill_hover_dark='*neutral_100',
277
+ button_secondary_border_color_dark='*neutral_200',
278
+ button_secondary_text_color_dark='*neutral_800'
279
+ )
280
+
281
+ with gr.Blocks(theme=theme, css=css) as demo:
282
+ with gr.Column(elem_id="col-container"):
283
+
284
+ gr.HTML("""
285
+ <h2 style="text-align: center;">SD-XL Control LoRas</h2>
286
+ <p style="text-align: center;">Use StableDiffusion XL with <a href="https://huggingface.co/collections/diffusers/sdxl-controlnets-64f9c35846f3f06f5abe351f">Diffusers' SDXL ControlNets</a></p>
287
+ """)
288
+
289
+ use_custom_model = gr.Checkbox(label="Use a custom pre-trained LoRa model ? (optional)", visible = False, value=False, info="To use a private model, you'll need to duplicate the space with your own access token.")
290
+
291
+ with gr.Blocks(visible=False) as custom_model_box:
292
+ with gr.Row():
293
+ with gr.Column():
294
+ if not is_shared_ui:
295
+ your_username = api.whoami()["name"]
296
+ my_models = api.list_models(author=your_username, filter=["diffusers", "stable-diffusion-xl", 'lora'])
297
+ model_names = [item.modelId for item in my_models]
298
+
299
+ if not is_shared_ui:
300
+ custom_model = gr.Dropdown(
301
+ label = "Your custom model ID",
302
+ info="You can pick one of your private models",
303
+ choices = model_names,
304
+ allow_custom_value = True
305
+ #placeholder = "username/model_id"
306
+ )
307
+ else:
308
+ custom_model = gr.Textbox(
309
+ label="Your custom model ID",
310
+ placeholder="your_username/your_trained_model_name",
311
+ info="Make sure your model is set to PUBLIC"
312
+ )
313
+
314
+ weight_name = gr.Dropdown(
315
+ label="Safetensors file",
316
+ #value="pytorch_lora_weights.safetensors",
317
+ info="specify which one if model has several .safetensors files",
318
+ allow_custom_value=True,
319
+ visible = False
320
+ )
321
+ with gr.Column():
322
+ with gr.Group():
323
+ load_model_btn = gr.Button("Load my model", elem_id="load_model_btn")
324
+ previous_model = gr.Textbox(
325
+ visible = False
326
+ )
327
+ model_status = gr.Textbox(
328
+ label = "model status",
329
+ show_label = False,
330
+ elem_id = "status_info"
331
+ )
332
+ trigger_word = gr.Textbox(label="Trigger word", interactive=False, visible=False)
333
+
334
+ image_in = gr.Image(sources="upload", type="filepath")
335
+
336
+ with gr.Row():
337
+
338
+ with gr.Column():
339
+ with gr.Group():
340
+ prompt = gr.Textbox(label="Prompt")
341
+ negative_prompt = gr.Textbox(label="Negative prompt", value="extra digit, fewer digits, cropped, worst quality, low quality, glitch, deformed, mutated, ugly, disfigured")
342
+ with gr.Group():
343
+ guidance_scale = gr.Slider(label="Guidance Scale", minimum=1.0, maximum=10.0, step=0.1, value=7.5)
344
+ inf_steps = gr.Slider(label="Inference Steps", minimum="25", maximum="50", step=1, value=25)
345
+ custom_lora_weight = gr.Slider(label="Custom model weights", minimum=0.1, maximum=0.9, step=0.1, value=0.9)
346
+
347
+ with gr.Column():
348
+ with gr.Group():
349
+ preprocessor = gr.Dropdown(label="Preprocessor", choices=["canny"], value="canny", interactive=False, info="For the moment, only canny is available")
350
+ controlnet_conditioning_scale = gr.Slider(label="Controlnet conditioning Scale", minimum=0.1, maximum=0.9, step=0.01, value=0.5)
351
+ with gr.Group():
352
+ seed = gr.Slider(
353
+ label="Seed",
354
+ info = "-1 denotes a random seed",
355
+ minimum=-1,
356
+ maximum=423538377342,
357
+ step=1,
358
+ value=-1
359
+ )
360
+ last_used_seed = gr.Number(
361
+ label = "Last used seed",
362
+ info = "the seed used in the last generation",
363
+ )
364
+
365
+
366
+ submit_btn = gr.Button("Submit")
367
+
368
+ result = gr.Image(label="Result")
369
+
370
+ use_custom_model.change(
371
+ fn = check_use_custom_or_no,
372
+ inputs =[use_custom_model],
373
+ outputs = [custom_model_box],
374
+ queue = False
375
+ )
376
+ custom_model.blur(
377
+ fn=custom_model_changed,
378
+ inputs = [custom_model, previous_model],
379
+ outputs = [model_status],
380
+ queue = False
381
+ )
382
+ load_model_btn.click(
383
+ fn = load_model,
384
+ inputs=[custom_model],
385
+ outputs = [previous_model, model_status, weight_name, trigger_word],
386
+ queue = False
387
+ )
388
+ submit_btn.click(
389
+ fn = infer,
390
+ inputs = [use_custom_model,custom_model, weight_name, custom_lora_weight, image_in, prompt, negative_prompt, preprocessor, controlnet_conditioning_scale, guidance_scale, inf_steps, seed],
391
+ outputs = [result, last_used_seed]
392
+ )
393
+
394
+ # return demo
395
+
396
+
397
+ demo.queue(max_size=12).launch(share=True)
viteGradio/another-page.html ADDED
@@ -0,0 +1,254 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <!-- <title>three.js webgl - multiple elements</title> -->
5
+ <meta charset="utf-8">
6
+ <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
7
+ <link type="text/css" rel="stylesheet" href="./src/App.css">
8
+ <style>
9
+ * {
10
+ box-sizing: border-box;
11
+ -moz-box-sizing: border-box;
12
+
13
+ /* top: -10%;
14
+ left: 50%;
15
+ transform: translate(-50%, 50%); */
16
+ }
17
+
18
+ body {
19
+ background-color: #fff;
20
+ color: #444;
21
+ }
22
+
23
+ a {
24
+ color: #08f;
25
+ }
26
+
27
+ #content {
28
+ position: absolute;
29
+ top: 0; width: 100%;
30
+ z-index: 1;
31
+ padding: 3em 3rem 0 3rem ;
32
+ }
33
+
34
+ #c {
35
+ position: absolute;
36
+ left: 0;
37
+ width: 100%;
38
+ height: 100%;
39
+ }
40
+
41
+ .list-item {
42
+ display: inline-block;
43
+ margin: 1em;
44
+ padding: 1em;
45
+ box-shadow: 1px 2px 4px 0px rgba(0,0,0,0.25);
46
+ }
47
+
48
+ .list-item > div:nth-child(1) {
49
+ width: 350px;
50
+ height: 220px;
51
+ }
52
+
53
+ .list-item > div:nth-child(2) {
54
+ color: #888;
55
+ font-family: sans-serif;
56
+ font-size: large;
57
+ width: 200px;
58
+ margin-top: 0.5em;
59
+ }
60
+ </style>
61
+ </head>
62
+ <body>
63
+
64
+ <canvas id="c"></canvas>
65
+ <div id="content">
66
+ <!-- <div id="info"><a href="https://threejs.org" target="_blank" rel="noopener">three.js</a> - multiple elements - webgl</div> -->
67
+ </div>
68
+
69
+ <script type="importmap">
70
+ {
71
+ "imports": {
72
+ "three": "../build/three.module.js",
73
+ "three/addons/": "./jsm/"
74
+ }
75
+ }
76
+ </script>
77
+
78
+ <script type="module">
79
+
80
+ import * as THREE from 'three';
81
+ import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
82
+
83
+ let canvas, renderer;
84
+ const scenes = [];
85
+
86
+ async function fetchImages() {
87
+ const response = await fetch('./images/names.json');
88
+ console.log(response)
89
+ const imageFiles = await response.json();
90
+
91
+ const imagePairs = pairImages(imageFiles);
92
+ init(imagePairs);
93
+ animate();
94
+ }
95
+
96
+ function pairImages(imageFiles) {
97
+ const resultImages = imageFiles.filter(file => file.startsWith('result'));
98
+ console.log(resultImages)
99
+ const imagePairs = [];
100
+
101
+ resultImages.forEach(resultImage => {
102
+ const resultNumber = resultImage.match(/\d+/)[0];
103
+ const depthImage = `depth${resultNumber}.png`;
104
+
105
+ if (imageFiles.includes(depthImage)) {
106
+ imagePairs.push({
107
+ map: `./images/${resultImage}`,
108
+ depthMap: `./images/${depthImage}`
109
+ });
110
+ }
111
+ });
112
+
113
+ return imagePairs;
114
+ }
115
+
116
+ function init(imagePairs) {
117
+
118
+ canvas = document.getElementById( 'c' );
119
+ let amap = new THREE.TextureLoader().load("result.png")
120
+ let dmap = new THREE.TextureLoader().load("depth.png")
121
+ const settings = {
122
+ metalness: 0.0,
123
+ roughness: 1,
124
+ //ambientIntensity: 0,
125
+ displacementScale: 5,
126
+ displacementBias: -0.5,
127
+ };
128
+
129
+ const geometries = [
130
+ new THREE.PlaneGeometry( 10, 10, 512, 512 ),
131
+ ];
132
+
133
+ const content = document.getElementById( 'content' );
134
+
135
+ for (let i = 0; i < imagePairs.length; i++) {
136
+ const scene = new THREE.Scene();
137
+
138
+ // make a list item
139
+ const element = document.createElement( 'div' );
140
+ element.className = 'list-item';
141
+
142
+ const sceneElement = document.createElement( 'div' );
143
+ element.appendChild( sceneElement );
144
+
145
+ scene.userData.element = sceneElement;
146
+ content.appendChild( element );
147
+
148
+ const camera = new THREE.PerspectiveCamera( 40, 1, 1, 10 );
149
+ camera.position.z = 12.5;
150
+ scene.userData.camera = camera;
151
+
152
+ const controls = new OrbitControls( scene.userData.camera, scene.userData.element );
153
+ controls.minDistance = 2;
154
+ controls.maxDistance = 5;
155
+ controls.enablePan = false;
156
+ controls.enableZoom = false;
157
+ scene.userData.controls = controls;
158
+
159
+ window.addEventListener("mousemove", onmousemove, false);
160
+ var plane = new THREE.Plane(new THREE.Vector3(1, 1, 0), 2);
161
+ var raycaster = new THREE.Raycaster();
162
+ var mouse = new THREE.Vector2();
163
+ var intersectPoint = new THREE.Vector3();
164
+
165
+ function onmousemove(event) {
166
+ mouse.x = (event.clientX / window.innerWidth) - 1;
167
+ mouse.y = -(event.clientY / window.innerHeight)- 1;
168
+ raycaster.setFromCamera(mouse, camera);
169
+ raycaster.ray.intersectPlane(plane, intersectPoint);
170
+ mesh.lookAt(intersectPoint);
171
+ }
172
+
173
+ const geometry = geometries[ geometries.length * Math.random() | 0 ];
174
+
175
+ const material = new THREE.MeshStandardMaterial( {
176
+ map: new THREE.TextureLoader().load(imagePairs[i].map),
177
+ displacementMap: new THREE.TextureLoader().load(imagePairs[i].depthMap),
178
+ emissive: 0xffffff,
179
+ emissiveIntensity: 0.9,
180
+ emissiveMap : new THREE.TextureLoader().load(imagePairs[i].map),
181
+ roughness: settings.roughness,
182
+ metalness: settings.metalness,
183
+ displacementScale: settings.displacementScale,
184
+ displacementBias: settings.displacementBias,
185
+ side: THREE.DoubleSide
186
+ } );
187
+
188
+ const mesh = new THREE.Mesh( geometry, material );
189
+ mesh.scale.set(0.6,0.6,0.6)
190
+ mesh.frustrumCulled = false
191
+ mesh.position.set(0,0,3)
192
+ scene.add( mesh );
193
+ scenes.push( scene );
194
+ }
195
+
196
+ renderer = new THREE.WebGLRenderer( { canvas: canvas, antialias: true } );
197
+ renderer.setClearColor( 0x000000, 0 );
198
+ renderer.setPixelRatio( window.devicePixelRatio );
199
+ }
200
+
201
+ function updateSize() {
202
+ const width = canvas.clientWidth;
203
+ const height = canvas.clientHeight;
204
+
205
+ if ( canvas.width !== width || canvas.height !== height ) {
206
+ renderer.setSize( width, height, false );
207
+ }
208
+ }
209
+
210
+ function animate() {
211
+ render();
212
+ requestAnimationFrame( animate );
213
+ }
214
+
215
+ function render() {
216
+ updateSize();
217
+
218
+ canvas.style.transform = `translateY(${window.scrollY}px)`;
219
+
220
+ renderer.setClearColor( 0xffffff );
221
+ renderer.setScissorTest( false );
222
+ renderer.clear();
223
+
224
+ renderer.setClearColor( 0xe0e0e0 );
225
+ renderer.setScissorTest( true );
226
+
227
+ scenes.forEach( function ( scene ) {
228
+ const element = scene.userData.element;
229
+ const rect = element.getBoundingClientRect();
230
+
231
+ if ( rect.bottom < 0 || rect.top > renderer.domElement.clientHeight ||
232
+ rect.right < 0 || rect.left > renderer.domElement.clientWidth ) {
233
+ return;
234
+ }
235
+
236
+ const width = rect.right - rect.left;
237
+ const height = rect.bottom - rect.top;
238
+ const left = rect.left;
239
+ const bottom = renderer.domElement.clientHeight - rect.bottom;
240
+
241
+ renderer.setViewport( left, bottom, width, height );
242
+ renderer.setScissor( left, bottom, width, height );
243
+
244
+ const camera = scene.userData.camera;
245
+ renderer.render( scene, camera );
246
+ });
247
+ }
248
+
249
+ fetchImages();
250
+
251
+ </script>
252
+
253
+ </body>
254
+ </html>
viteGradio/dist/index.2cdaf7bc.css ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ body {
2
+ margin: 0;
3
+ font-family: sans-serif;
4
+ }
5
+
6
+ .dropzone {
7
+ box-sizing: border-box;
8
+ z-index: 99999;
9
+ background: rgba(#60a7dc, .8);
10
+ border: 11px dashed #60a7dc;
11
+ width: 100%;
12
+ height: 100%;
13
+ display: none;
14
+ position: fixed;
15
+ top: 0;
16
+ left: 0;
17
+ }
18
+
19
+ /*# sourceMappingURL=index.2cdaf7bc.css.map */
viteGradio/dist/index.2cdaf7bc.css.map ADDED
@@ -0,0 +1 @@
 
 
1
+ {"mappings":"AAAA;;;;;AAIA","sources":["src/style.css"],"sourcesContent":["body {\r\n font-family: sans-serif;\r\n margin: 0;\r\n}\r\n.dropzone {\r\n\tbox-sizing: border-box;\r\n\tdisplay: none;\r\n\tposition: fixed;\r\n\twidth: 100%;\r\n height: 100%;\r\n left: 0;\r\n top: 0;\r\n z-index: 99999;\r\n\tbackground: rgba(#60a7dc,.8);\r\n\tborder: 11px dashed #60a7dc;\r\n}"],"names":[],"version":3,"file":"index.2cdaf7bc.css.map","sourceRoot":"/__parcel_source_root/"}
viteGradio/dist/index.975ef6c8.js ADDED
The diff for this file is too large to render. See raw diff
 
viteGradio/dist/index.975ef6c8.js.map ADDED
The diff for this file is too large to render. See raw diff
 
viteGradio/dist/index.html ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>depthmap-viewer-three</title>
6
+ <link rel="stylesheet" href="/index.2cdaf7bc.css">
7
+ <script src="/index.975ef6c8.js" defer=""></script>
8
+ </head>
9
+ <body>
10
+ <div id="dropzone" class="dropzone"></div>
11
+ </body>
12
+ </html>
viteGradio/dist/roots2_rgbd.c6f8f977.png ADDED

Git LFS Details

  • SHA256: 4ceb8d26a3de840c5f3dde261e7ff5550bace36ac6d4bef4b4244f6bff5371a9
  • Pointer size: 132 Bytes
  • Size of remote file: 1.6 MB
viteGradio/images/depth.png ADDED
viteGradio/images/depth1.png ADDED
viteGradio/images/depth2.png ADDED
viteGradio/images/depth3.png ADDED
viteGradio/images/depth4.png ADDED
viteGradio/images/depth5.png ADDED
viteGradio/images/depth6.png ADDED
viteGradio/images/names.json ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ "result1.png",
3
+ "depth1.png",
4
+ "result2.png",
5
+ "depth2.png",
6
+ "result3.png",
7
+ "depth3.png",
8
+ "result4.png",
9
+ "depth4.png",
10
+ "result5.png",
11
+ "depth5.png",
12
+ "result6.png",
13
+ "depth6.png"
14
+ ]
15
+
viteGradio/images/result.png ADDED

Git LFS Details

  • SHA256: 0fc40b580a7e0ee95274e4f54a6f1f1a6ca4c50220f8087738275ca7dbb596a0
  • Pointer size: 132 Bytes
  • Size of remote file: 3.21 MB
viteGradio/images/result1.png ADDED

Git LFS Details

  • SHA256: 3fbea1c2141093605817ee87bb2fb2514b53f8e7cfef50e74dbaac1efb47cfc3
  • Pointer size: 132 Bytes
  • Size of remote file: 3.5 MB
viteGradio/images/result2.png ADDED

Git LFS Details

  • SHA256: 27aea37254002f83d31d62eea02ecec23d0b22ed5153683220602b05629f282a
  • Pointer size: 132 Bytes
  • Size of remote file: 3.72 MB
viteGradio/images/result3.png ADDED

Git LFS Details

  • SHA256: f5b38b26e6d7e998f60c07c9841d940734e55689d0ee8eea8828f019901d4ef1
  • Pointer size: 132 Bytes
  • Size of remote file: 2.4 MB
viteGradio/images/result4.png ADDED

Git LFS Details

  • SHA256: 1dcf226d4658f00268632968b62f6a7f9fbbb48b5b23eda4a6d36ac6335c8fad
  • Pointer size: 132 Bytes
  • Size of remote file: 3.5 MB
viteGradio/images/result5.png ADDED

Git LFS Details

  • SHA256: c12d8b369675c6e6fc8d99fe5888fc7a168e3e0c605674e4c932f0b9f5952c23
  • Pointer size: 132 Bytes
  • Size of remote file: 3.97 MB
viteGradio/images/result6.png ADDED

Git LFS Details

  • SHA256: bc8a16c22cb0950eb46ec22377e8320c21424a75aec6f4d0b7a0c8b929f235bb
  • Pointer size: 132 Bytes
  • Size of remote file: 3.5 MB
viteGradio/index.html ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <link rel="icon" type="image/svg+xml" href="/vite.svg" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <title>Vite + React</title>
8
+ <style>
9
+ /* Add a style block to set z-index for the link */
10
+ a {
11
+ position: fixed; /* Make the link fixed position */
12
+ top: 10px; /* Adjust the top position as needed */
13
+ left: 10px; /* Adjust the left position as needed */
14
+ z-index: 9999; /* Set a high z-index value */
15
+ }
16
+ </style>
17
+ </head>
18
+ <body>
19
+ <div id="root"></div>
20
+ <script type="module" src="/src/main.jsx"></script>
21
+ <!-- <a href="another-page.html">Go to Another Page</a> -->
22
+ <div id="dropzone" class="dropzone"></div>
23
+
24
+ <script
25
+ type="module"
26
+ src="https://gradio.s3-us-west-2.amazonaws.com/4.3.0/gradio.js"
27
+ ></script>
28
+
29
+ </body>
30
+ </html>
viteGradio/package-lock.json ADDED
The diff for this file is too large to render. See raw diff
 
viteGradio/package.json ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "vitegradio",
3
+ "private": true,
4
+ "version": "0.0.0",
5
+ "type": "module",
6
+ "scripts": {
7
+ "dev": "vite",
8
+ "build": "vite build",
9
+ "lint": "eslint . --ext js,jsx --report-unused-disable-directives --max-warnings 0",
10
+ "preview": "vite preview"
11
+ },
12
+ "dependencies": {
13
+ "react": "^18.2.0",
14
+ "react-dom": "^18.2.0",
15
+ "react-router-dom": "^6.18.0",
16
+ "three": "^0.158.0"
17
+ },
18
+ "devDependencies": {
19
+ "@gradio/client": "^0.8.0",
20
+ "@types/react": "^18.2.15",
21
+ "@types/react-dom": "^18.2.7",
22
+ "@vitejs/plugin-react-swc": "^3.3.2",
23
+ "eslint": "^8.45.0",
24
+ "eslint-plugin-react": "^7.32.2",
25
+ "eslint-plugin-react-hooks": "^4.6.0",
26
+ "eslint-plugin-react-refresh": "^0.4.3",
27
+ "vite": "^4.4.5"
28
+ }
29
+ }
viteGradio/public/SUNS.png ADDED
viteGradio/public/intro2.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ac96426c658432be6b256ad0e587317721f0cf633ac26611b65a8f8879e528de
3
+ size 1002761
viteGradio/public/vite.svg ADDED
viteGradio/src/3Dviewer.jsx ADDED
@@ -0,0 +1,153 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import * as THREE from 'three';
2
+
3
+ // import { OrbitControls } from "three/examples/jsm/controls/OrbitControls";
4
+ // import { GUI } from 'three/examples/jsm/libs/lil-gui.module.min.js';
5
+
6
+ import MyTexture from "./../images/result.png";
7
+ import MyDepth from "./../images/depth.png";
8
+
9
+ import './App.css';
10
+ const renderer = new THREE.WebGLRenderer({ antialias: true });
11
+
12
+ function Render3D(isVisible) {
13
+ let mesh;
14
+ let material;
15
+ let image_ar;
16
+
17
+ const settings = {
18
+ metalness: 0.0,
19
+ roughness: 0.14,
20
+ ambientIntensity: 0.85,
21
+ displacementScale: 5,
22
+ displacementBias: -0.5,
23
+ // emissive: 0xffffff,
24
+ };
25
+
26
+ // init
27
+ const camera = new THREE.PerspectiveCamera( 50, window.innerWidth / window.innerHeight, 1, 1000);
28
+ camera.position.z = 8.5;
29
+
30
+ const scene = new THREE.Scene();
31
+
32
+ // const ambientLight = new THREE.AmbientLight( 0xffffff, 4 );
33
+ // scene.add( ambientLight );
34
+
35
+ // const pointLight = new THREE.PointLight( 0xff0000, 1 );
36
+ // pointLight.position.z = 2500;
37
+ // scene.add( pointLight );
38
+ scene.background = new THREE.Color( 0xffffff );
39
+ // const renderer = new THREE.WebGLRenderer( { antialias: true } );
40
+ renderer.setSize( window.innerWidth/2, window.innerHeight/2 );
41
+ renderer.setAnimationLoop( animation );
42
+ // renderer.toneMapping = THREE.ACESFilmicToneMapping;
43
+ // renderer.toneMappingExposure = 1;
44
+ // renderer.outputColorSpace = THREE.SRGBColorSpace;
45
+ document.body.appendChild( renderer.domElement )
46
+
47
+ // animation
48
+ window.addEventListener("mousemove", onmousemove, false);
49
+ var plane = new THREE.Plane(new THREE.Vector3(0, 1, 0), 0.5); // it's up to you how you will create THREE.Plane(), there are several methods
50
+ var raycaster = new THREE.Raycaster(); //for reuse
51
+ var mouse = new THREE.Vector2(); //for reuse
52
+ var intersectPoint = new THREE.Vector3();//for reuse
53
+
54
+ function onmousemove(event) {
55
+ //get mouse coordinates
56
+ mouse.x = (event.clientX / window.innerWidth) - 1;
57
+ mouse.y = -(event.clientY / window.innerHeight)- 1;
58
+ raycaster.setFromCamera(mouse, camera);//set raycaster
59
+ raycaster.ray.intersectPlane(plane, intersectPoint); // find the point of intersection
60
+ mesh.lookAt(intersectPoint); // face our arrow to this point
61
+ }
62
+
63
+ function animation( time ) {
64
+ renderer.render( scene, camera );
65
+ }
66
+
67
+ function onWindowResize() {
68
+
69
+ const aspect = window.innerWidth / window.innerHeight;
70
+ camera.aspect = aspect;
71
+ camera.updateProjectionMatrix();
72
+
73
+ renderer.setSize( window.innerWidth/2, window.innerHeight/2 );
74
+ }
75
+ window.addEventListener( 'resize', onWindowResize );
76
+
77
+
78
+ // orbit controls
79
+ // const controls = new OrbitControls( camera, renderer.domElement );
80
+ // controls.enableZoom = false;
81
+ // controls.enableDamping = false;
82
+
83
+
84
+ const image = new Image();
85
+ const image2 = new Image();
86
+ (image.onload) = function() {
87
+
88
+ if (mesh) {
89
+ mesh.geometry.dispose();
90
+ mesh.material.dispose();
91
+ scene.remove( mesh );
92
+ }
93
+
94
+ image_ar = image.width / image.height ;
95
+
96
+ const ctx = document.createElement('canvas').getContext('2d');
97
+ ctx.canvas.width = image.width;
98
+ ctx.canvas.height = image.height;
99
+ ctx.drawImage(image, 0, 0);
100
+ const myrgbmap = new THREE.CanvasTexture(ctx.canvas);
101
+
102
+ const ctx2 = document.createElement('canvas').getContext('2d');
103
+ ctx2.canvas.width = image2.width;
104
+ ctx2.canvas.height = image2.height;
105
+ ctx2.drawImage(image2, 0, 0);
106
+ const mydepthmap = new THREE.CanvasTexture(ctx2.canvas);
107
+
108
+
109
+ // material
110
+ material = new THREE.MeshStandardMaterial( {
111
+ color: 0xaaaaaa,
112
+ map: myrgbmap,
113
+ displacementMap: mydepthmap,
114
+ emissive: 0xffffff,
115
+ emissiveIntensity: 0.9,
116
+ emissiveMap : myrgbmap,
117
+ roughness: settings.roughness,
118
+ metalness: settings.metalness,
119
+ displacementScale: settings.displacementScale,
120
+ displacementBias: settings.displacementBias,
121
+ side: THREE.DoubleSide
122
+ } );
123
+
124
+ // generating geometry and add mesh to scene
125
+ const geometry = new THREE.PlaneGeometry( 10, 10, 512, 512 );
126
+ mesh = new THREE.Mesh( geometry, material );
127
+ mesh.scale.y = 1.0 / image_ar;
128
+ mesh.scale.multiplyScalar( 0.5);
129
+ scene.add( mesh );
130
+
131
+ }
132
+ image.src = MyTexture;
133
+ image2.src = MyDepth;
134
+ }
135
+
136
+ function Viewer3D({ isVisible }) {
137
+ // console.log("called ")
138
+ renderer.clear();
139
+ renderer.setSize( 0, 0);
140
+
141
+ return (
142
+ <>
143
+ {isVisible ? (
144
+ <div style={{ position: 'static', display: 'inline-block' }}>
145
+ <Render3D isVisible={isVisible} />
146
+ </div>
147
+ ) : null}
148
+ {/* <iframe src="./../another-page.html" width="100%" height="1000px" frameborder="0"></iframe> */}
149
+ </>
150
+ );
151
+ }
152
+
153
+ export default Viewer3D;
viteGradio/src/App.css ADDED
@@ -0,0 +1,172 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ html
2
+ #root {
3
+ /* max-width: 1280px;
4
+ margin: 0 auto; */
5
+ width: 100%;
6
+ /* padding: 2rem 2rem 2rem 2rem; */
7
+ text-align: center;
8
+ font-family: 'Montserrat', sans-serif;
9
+ color: #707070;
10
+ /* font-size: 1.3vw; */
11
+ --darkteal: #1fcfbb;
12
+ --teal:#99F6E4;
13
+ --lightteal: rgb(16, 16, 16);
14
+ --gray:#D1D5DB;
15
+ --lightgray: #E5E7EB;
16
+ position: absolute;
17
+ top:50px;
18
+ /* overflow-x: hidden; */
19
+ }
20
+ /*
21
+ canvas {
22
+ position: absolute;
23
+ top: -10%;
24
+ left: 50%;
25
+ transform: translate(-50%, 50%);
26
+ } */
27
+
28
+ .centered-container {
29
+ display: flex;
30
+ justify-content: center;
31
+ align-items: center;
32
+ top: 70%;
33
+ left: 50%;
34
+ transform: translate(-50%, 50%);
35
+ z-index: 100;
36
+ position: absolute;
37
+ }
38
+
39
+ .centered-container :hover {
40
+ background-color: var(--teal);
41
+ border-color: transparent;
42
+ }
43
+
44
+ .centered-container :focus :active {
45
+ border-color: transparent;
46
+ }
47
+
48
+ .centered-container button {
49
+ background-color: var(--darkteal);
50
+ outline: none; /* Remove outline on button */
51
+ }
52
+
53
+ .image-generator-container {
54
+ display: flex;
55
+ flex-direction: column;
56
+ align-items: center;
57
+ margin: 20px;
58
+ }
59
+
60
+ .buttonContainer {
61
+ top:0;
62
+ position: relative;
63
+ display: flex;
64
+ gap: 5%;
65
+ padding-left: 60%;
66
+
67
+ }
68
+
69
+ .buttonGroup {
70
+ width: 100px;
71
+ }
72
+
73
+ .circularButton {
74
+ width: 40px;
75
+ height: 40px;
76
+ border-radius: 50%;
77
+ background-color: var(--darkteal);
78
+ color: #ffffff;
79
+ border: none;
80
+ cursor: pointer;
81
+ /* padding: 0px; */
82
+ top:0;
83
+ position: relative;
84
+ display: flex;
85
+ justify-content: space-around;
86
+ }
87
+
88
+ .buttonText {
89
+ margin-top: 20px;
90
+ top:0;
91
+ position: relative;
92
+ }
93
+ /* App.css */
94
+ .visible {
95
+ display: block;
96
+ }
97
+
98
+ .hidden {
99
+ display: none;
100
+ }
101
+
102
+
103
+ .logo{
104
+ top:0;
105
+ position: absolute;
106
+ left:0;
107
+ padding: 0 2% 2% 2%;
108
+ }
109
+
110
+ .form-container {
111
+ margin-bottom: 20px;
112
+ }
113
+
114
+ label {
115
+ margin-right: 10px;
116
+ }
117
+
118
+ input {
119
+ margin-right: 10px;
120
+ }
121
+
122
+ .image-container img {
123
+ max-width: 100%;
124
+ height: auto;
125
+ border: 1px solid #ccc;
126
+ border-radius: 8px;
127
+ box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
128
+ margin-top: 10px;
129
+ }
130
+
131
+ button {
132
+ position: relative;
133
+ padding: 5%;
134
+ background-color: #007bff;
135
+ border-radius: 5%;
136
+ color: #fff;
137
+ border: none;
138
+ cursor: pointer;
139
+ top: 50%;
140
+ left: 50%;
141
+ transform: translate(-50%, 50%);
142
+ }
143
+
144
+
145
+
146
+
147
+ .container {
148
+ max-width: 600px;
149
+ margin: auto;
150
+ padding: 20px;
151
+ text-align: center;
152
+ }
153
+
154
+ form {
155
+ display: flex;
156
+ flex-direction: column;
157
+ gap: 10px;
158
+ margin-bottom: 20px;
159
+ }
160
+
161
+ label {
162
+ font-weight: bold;
163
+ }
164
+
165
+ .image-box {
166
+ margin-top: 20px;
167
+ }
168
+
169
+ img {
170
+ max-width: 100%;
171
+ height: auto;
172
+ }
viteGradio/src/App.jsx ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // App.js
2
+ import React, { useState } from 'react';
3
+ import Header from './Header';
4
+ import VisualisationPage from './VisualisationPage';
5
+ import ReviewPage from './ReviewPage';
6
+ import PromptPage from './PromptPage';
7
+ import Viewer3D from './3Dviewer';
8
+ import { BrowserRouter as Router, Route, Routes } from 'react-router-dom';
9
+
10
+ //import ThreeJSComponent from './multiple3D';
11
+
12
+ // import GeneratePage from './components/GeneratePage';
13
+ import './App.css';
14
+
15
+ function App() {
16
+ const [currentPage, setCurrentPage] = useState('Visualisation');
17
+
18
+ const handleButtonClick = (page) => {
19
+ setCurrentPage(page);
20
+ };
21
+
22
+ return (
23
+ <>
24
+ <div>
25
+ <Header onPageButtonClick={handleButtonClick} style={{zIndex:'100'}}/>
26
+ {/* <ThreeJSComponent/> */}
27
+ <VisualisationPage onPageButtonClick={handleButtonClick} isVisible={currentPage === 'Visualisation'} />
28
+ <ReviewPage isVisible={currentPage === 'Review'} />
29
+ <PromptPage isVisible={currentPage === 'Prompt'} />
30
+ <Viewer3D isVisible={currentPage === 'Generate'} />
31
+
32
+ <Router>
33
+ <div>
34
+
35
+ <Routes>
36
+ <Route path="/generate" element={<Viewer3D/>} />
37
+ </Routes>
38
+ </div>
39
+ </Router>
40
+
41
+ </div>
42
+ </>
43
+ );
44
+ }
45
+
46
+ export default App;
viteGradio/src/Header.jsx ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Header.js
2
+ import React, { useState } from 'react';
3
+ import './App.css';
4
+
5
+ function Header({ onPageButtonClick }) {
6
+ return (
7
+ <>
8
+ <div>
9
+ <img src="./SUNS.png" className="logo" alt="SUNS" />
10
+ <div className="buttonContainer">
11
+ <div className="buttonGroup">
12
+ <button className="circularButton" onClick={() => onPageButtonClick('Visualisation')}>
13
+ 1
14
+ </button>
15
+ <div className="buttonText">Visualisation</div>
16
+ </div>
17
+ <div className="buttonGroup">
18
+ <button className="circularButton" onClick={() => onPageButtonClick('Review')}>
19
+ 2
20
+ </button>
21
+ <div className="buttonText">Review</div>
22
+ </div>
23
+ <div className="buttonGroup">
24
+ <button className="circularButton" onClick={() => onPageButtonClick('Prompt')}>
25
+ 3
26
+ </button>
27
+ <div className="buttonText">Prompt</div>
28
+ </div>
29
+ <div className="buttonGroup">
30
+ <button className="circularButton" onClick={() => onPageButtonClick('Generate')}>
31
+ 4
32
+ </button>
33
+ <div className="buttonText">Generate</div>
34
+ </div>
35
+ </div>
36
+ </div>
37
+ </>
38
+ );
39
+ }
40
+
41
+ export default Header;
viteGradio/src/PromptPage.jsx ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React, { useState, useEffect } from 'react';
2
+ import Test from './components/test';
3
+ import ImageGenerationForm from './components/sdxl';
4
+ import Original from './components/original';
5
+ import Header from './Header';
6
+ import './App.css';
7
+
8
+ function PromptPage({ isVisible }) {
9
+ const handleButtonClick = () => {
10
+ // Calculate the scroll position to scroll to half the page
11
+ const halfPageScroll = window.innerHeight * 0.8;
12
+ //console.log(window.scroll)
13
+ // Scroll down to half the page
14
+ window.scrollTo({
15
+ top: 1000,
16
+ behavior: 'smooth', // Add smooth scrolling animation
17
+ });
18
+ };
19
+
20
+
21
+
22
+ return (
23
+ <>
24
+ <div className={isVisible ? 'visible' : 'hidden'} style={{ overflow: 'auto', maxHeight: '1000px' }}>
25
+ {/* <gradio-app eager="true" src="https://48d319625c8a1616e3.gradio.live/"></gradio-app> */}
26
+ <button onClick={handleButtonClick}>Scroll to Half Page</button>
27
+ <h1>LOADING</h1>
28
+ <iframe src="./../another-page.html" width="100%" height="1000px" frameBorder="0"></iframe>
29
+
30
+ </div>
31
+ </>
32
+ );
33
+ }
34
+
35
+ export default PromptPage;
viteGradio/src/ReviewPage.jsx ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React, { useState } from 'react';
2
+ import Test from './components/test';
3
+ import ImageGenerationForm from './components/sdxl';
4
+ import Original from './components/original';
5
+ import Header from './Header';
6
+ import './App.css';
7
+
8
+ function ReviewPage({ isVisible }) {
9
+
10
+ return (
11
+ <>
12
+ <div className={isVisible ? 'visible' : 'hidden'}>
13
+ {/* <gradio-app src="https://claireozzz-sdxl-control-loras.hf.space"></gradio-app> */}
14
+ </div>
15
+ </>
16
+ );
17
+ }
18
+
19
+ export default ReviewPage;
viteGradio/src/VisualisationPage.jsx ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React from 'react';
2
+ import './App.css';
3
+
4
+ function VisualisationPage( props ) {
5
+ return (
6
+ <>
7
+ <div className={props.isVisible ? 'visible' : 'hidden'}>
8
+ <video width="95%" height="95%" autoPlay muted playsInline controls={false}>
9
+ <source src="./intro2.mp4" type="video/mp4" />
10
+ Your browser does not support the video tag.
11
+ </video>
12
+
13
+ <div className="centered-container">
14
+ <button
15
+ onClick={() => props.onPageButtonClick('Review')}
16
+ >Begin</button>
17
+ </div>
18
+ </div>
19
+ </>
20
+ );
21
+ }
22
+
23
+ export default VisualisationPage;
viteGradio/src/assets/image (2).png ADDED
viteGradio/src/assets/input.png ADDED

Git LFS Details

  • SHA256: 9a32669ea57a65524e05d305b3aa1c295373538179059ee73c6b2bcaa29c6a69
  • Pointer size: 132 Bytes
  • Size of remote file: 2.37 MB
viteGradio/src/assets/output.jpg ADDED
viteGradio/src/assets/react.svg ADDED
viteGradio/src/assets/roots2_rgbd.png ADDED

Git LFS Details

  • SHA256: 4ceb8d26a3de840c5f3dde261e7ff5550bace36ac6d4bef4b4244f6bff5371a9
  • Pointer size: 132 Bytes
  • Size of remote file: 1.6 MB
viteGradio/src/assets/shop.jpeg ADDED
viteGradio/src/assets/shop2.png ADDED
viteGradio/src/assets/shopd.png ADDED
viteGradio/src/assets/shopt.jpeg ADDED
viteGradio/src/components/api.jsx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ const Api = "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";
2
+
3
+ export default Api;
viteGradio/src/components/original.jsx ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React, { useState } from "react";
2
+
3
+ import Api from './api';
4
+
5
+ const Original = () => {
6
+ const [loading, setLoading] = useState(false);
7
+ const [output, setOutput] = useState(null);
8
+
9
+ const handleSubmit = async (event) => {
10
+ event.preventDefault();
11
+ setLoading(true);
12
+
13
+ const input = event.target.elements.input.value;
14
+ const response = await fetch(
15
+ "https://79c67b7467ac6c1889.gradio.live/",
16
+ {
17
+ method: "POST",
18
+ headers: {
19
+ "Content-Type": "application/json",
20
+ Authorization: `Bearer ${Api}`,
21
+ },
22
+ body: JSON.stringify({ inputs: input, }),
23
+ }
24
+ );
25
+
26
+ if (!response.ok) {
27
+ throw new Error("Failed to generate image");
28
+ }
29
+
30
+ const blob = await response.blob();
31
+ setOutput(URL.createObjectURL(blob));
32
+ setLoading(false);
33
+ };
34
+
35
+ return (<div className="container al-c mt-3">
36
+ <h1>Stable <span>Diffusion</span></h1>
37
+ <p>Pellentesque vulputate dignissim enim, et sollicitudin massa pellentesque ut. Proin luctus dui ut sem varius eleifend.</p>
38
+ <form className="gen-form" onSubmit={handleSubmit}>
39
+ <input type="text" name="input" placeholder="type your prompt here..." />
40
+ <button type="submit">Generate</button>
41
+ </form>
42
+ <div>
43
+ {loading && <div className="loading">Loading...</div>}
44
+ {!loading && output && (
45
+ <div className="result-image">
46
+ <img src={output} alt="art" />
47
+ </div>
48
+ )}
49
+ </div>
50
+
51
+ </div>);
52
+
53
+ };
54
+
55
+ export default Original;