Sumant Bobade commited on
Commit
636bcf4
·
1 Parent(s): 552a55c

Second Commit

Browse files
Files changed (2) hide show
  1. app.py +35 -0
  2. index.html +182 -0
app.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import numpy as np
3
+ import torch
4
+ from diffusers import DiffusionPipeline
5
+ from PIL import Image
6
+
7
+ multi_view_diffusion_pipeline = DiffusionPipeline.from_pretrained(
8
+ "dylanebert/multi-view-diffusion",
9
+ custom_pipeline="dylanebert/multi-view-diffusion",
10
+ torch_dtype=torch.float16,
11
+ trust_remote_code=True,
12
+ ).to("cuda")
13
+
14
+
15
+ def run(image):
16
+ image = np.array(image, dtype=np.float32) / 255.0
17
+ images = multi_view_diffusion_pipeline(
18
+ "", image, guidance_scale=5, num_inference_steps=30, elevation=0
19
+ )
20
+
21
+ images = [Image.fromarray((img * 255).astype("uint8")) for img in images]
22
+
23
+ width, height = images[0].size
24
+ grid_img = Image.new("RGB", (2 * width, 2 * height))
25
+
26
+ grid_img.paste(images[0], (0, 0))
27
+ grid_img.paste(images[1], (width, 0))
28
+ grid_img.paste(images[2], (0, height))
29
+ grid_img.paste(images[3], (width, height))
30
+
31
+ return grid_img
32
+
33
+
34
+ demo = gr.Interface(fn=run, inputs="image", outputs="image")
35
+ demo.launch()
index.html ADDED
@@ -0,0 +1,182 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+
4
+ <head>
5
+ <meta charset="UTF-8">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
+
8
+ <title>Trellis Image → 3D Generator</title>
9
+
10
+ <script type="module"
11
+ src="https://gradio.s3-us-west-2.amazonaws.com/5.34.2/gradio.js">
12
+ </script>
13
+
14
+ <style>
15
+
16
+ @import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600&display=swap');
17
+
18
+ *{
19
+ margin:0;
20
+ padding:0;
21
+ box-sizing:border-box;
22
+ font-family:Poppins, sans-serif;
23
+ }
24
+
25
+ body{
26
+
27
+ background: linear-gradient(135deg,#0f172a,#020617);
28
+
29
+ color:white;
30
+
31
+ min-height:100vh;
32
+
33
+ display:flex;
34
+
35
+ flex-direction:column;
36
+
37
+ align-items:center;
38
+
39
+ }
40
+
41
+ /* Header */
42
+
43
+ .header{
44
+
45
+ width:100%;
46
+
47
+ padding:20px;
48
+
49
+ text-align:center;
50
+
51
+ background:rgba(255,255,255,0.05);
52
+
53
+ backdrop-filter: blur(10px);
54
+
55
+ border-bottom:1px solid rgba(255,255,255,0.1);
56
+
57
+ }
58
+
59
+ .header h1{
60
+
61
+ font-size:28px;
62
+
63
+ font-weight:600;
64
+
65
+ background:linear-gradient(90deg,#38bdf8,#818cf8);
66
+
67
+ -webkit-background-clip:text;
68
+
69
+ color:transparent;
70
+
71
+ }
72
+
73
+ .header p{
74
+
75
+ opacity:.7;
76
+
77
+ margin-top:8px;
78
+
79
+ font-size:14px;
80
+
81
+ }
82
+
83
+ /* Container */
84
+
85
+ .container{
86
+
87
+ width:95%;
88
+
89
+ max-width:1400px;
90
+
91
+ margin-top:25px;
92
+
93
+ background:rgba(255,255,255,0.04);
94
+
95
+ border-radius:15px;
96
+
97
+ padding:20px;
98
+
99
+ box-shadow:0 0 40px rgba(0,0,0,0.6);
100
+
101
+ border:1px solid rgba(255,255,255,0.08);
102
+
103
+ }
104
+
105
+ /* iframe styling */
106
+
107
+ iframe{
108
+
109
+ width:100%;
110
+
111
+ height:80vh;
112
+
113
+ border:none;
114
+
115
+ border-radius:10px;
116
+
117
+ background:black;
118
+
119
+ }
120
+
121
+ /* Footer */
122
+
123
+ .footer{
124
+
125
+ margin-top:15px;
126
+
127
+ opacity:.5;
128
+
129
+ font-size:13px;
130
+
131
+ }
132
+
133
+ /* Responsive */
134
+
135
+ @media(max-width:900px){
136
+
137
+ iframe{
138
+
139
+ height:75vh;
140
+
141
+ }
142
+
143
+ .header h1{
144
+
145
+ font-size:22px;
146
+
147
+ }
148
+
149
+ }
150
+
151
+ </style>
152
+
153
+ </head>
154
+
155
+ <body>
156
+
157
+ <div class="header">
158
+
159
+ <h1>Image → 3D Asset Generator</h1>
160
+
161
+ <p>Generate 3D models from images using TRELLIS diffusion</p>
162
+
163
+ </div>
164
+
165
+
166
+ <div class="container">
167
+
168
+ <iframe
169
+ src="https://trellis-community-trellis.hf.space"
170
+ ></iframe>
171
+
172
+ </div>
173
+
174
+ <div class="footer">
175
+
176
+ GEN-AI Project • VIIT
177
+
178
+ </div>
179
+
180
+ </body>
181
+
182
+ </html>