radames commited on
Commit
551a5ac
·
1 Parent(s): 2416b9c

better layout

Browse files
frontend/src/data.ts CHANGED
@@ -27,9 +27,9 @@ export const COLOR_LIST: Color[] = [
27
  { color: [50, 155, 250], label: 'wrist wearing' }
28
  ];
29
 
30
- // export const API = 'https://hf.space/embed/radames/Text2Human-API';
31
- export const API = 'https://hf.space/embed/CVPR/Text2Human';
32
-
33
  export const IMAGES_LIST = [
34
  '/samples/MEN-Pants-id_00002565-02_1_front_segm.png',
35
  '/samples/MEN-Pants-id_00005213-02_4_full_segm.png',
 
27
  { color: [50, 155, 250], label: 'wrist wearing' }
28
  ];
29
 
30
+ export const API = 'https://hf.space/embed/radames/Text2Human-API';
31
+ // export const API = 'https://hf.space/embed/CVPR/Text2Human';
32
+ //
33
  export const IMAGES_LIST = [
34
  '/samples/MEN-Pants-id_00002565-02_1_front_segm.png',
35
  '/samples/MEN-Pants-id_00005213-02_4_full_segm.png',
frontend/src/lib/DrawingCanvas.svelte CHANGED
@@ -68,8 +68,8 @@
68
  }
69
  function pointerMove(e: MouseEvent) {
70
  const position = getPosition(canvas, e);
71
- brush.style.top = `${position.y}px`;
72
- brush.style.left = `${position.x}px`;
73
  if (!mouseDown) {
74
  return;
75
  }
@@ -94,8 +94,8 @@
94
  function getPosition(canvas: HTMLCanvasElement, event: MouseEvent) {
95
  const rect = canvas.getBoundingClientRect();
96
  return {
97
- x: event.clientX - rect.left,
98
- y: event.clientY - rect.top
99
  };
100
  }
101
  function setBrush(sBrush: Brush) {
@@ -157,7 +157,7 @@
157
  </script>
158
 
159
  <div>
160
- <div class="inline-block relative overflow-clip">
161
  <canvas
162
  bind:this={canvas}
163
  class="canvas"
@@ -175,7 +175,7 @@
175
  <canvas bind:this={brush} class="brush" width="10" height="10" />
176
  <span class="label">{$selectedBrush?.label} </span>
177
  <button
178
- class="absolute bottom-1 left-1"
179
  on:click|preventDefault={() => rollBack()}
180
  disabled={$drawingLayers.size <= 0}><UndoIcon /></button
181
  >
@@ -184,7 +184,7 @@
184
 
185
  <style lang="postcss" scoped>
186
  .canvas {
187
- @apply box-border z-0 border dark:border-gray-300 border-gray-500 aspect-[256/512];
188
  }
189
  .brush {
190
  @apply z-10 absolute pointer-events-none -translate-x-1/2 -translate-y-1/2;
 
68
  }
69
  function pointerMove(e: MouseEvent) {
70
  const position = getPosition(canvas, e);
71
+ brush.style.top = `${e.offsetY}px`;
72
+ brush.style.left = `${e.offsetX}px`;
73
  if (!mouseDown) {
74
  return;
75
  }
 
94
  function getPosition(canvas: HTMLCanvasElement, event: MouseEvent) {
95
  const rect = canvas.getBoundingClientRect();
96
  return {
97
+ x: (event.clientX - rect.left) * (canvas.width / rect.width),
98
+ y: (event.clientY - rect.top) * (canvas.height / rect.height)
99
  };
100
  }
101
  function setBrush(sBrush: Brush) {
 
157
  </script>
158
 
159
  <div>
160
+ <div class="relative overflow-clip">
161
  <canvas
162
  bind:this={canvas}
163
  class="canvas"
 
175
  <canvas bind:this={brush} class="brush" width="10" height="10" />
176
  <span class="label">{$selectedBrush?.label} </span>
177
  <button
178
+ class="absolute bottom-2 left-2"
179
  on:click|preventDefault={() => rollBack()}
180
  disabled={$drawingLayers.size <= 0}><UndoIcon /></button
181
  >
 
184
 
185
  <style lang="postcss" scoped>
186
  .canvas {
187
+ @apply max-w-full w-full z-0 border dark:border-gray-300 border-gray-500 aspect-[256/512];
188
  }
189
  .brush {
190
  @apply z-10 absolute pointer-events-none -translate-x-1/2 -translate-y-1/2;
frontend/src/lib/ResultCanvas.svelte CHANGED
@@ -42,9 +42,11 @@
42
  }
43
  a.href = base64Image;
44
  };
45
- a.click();
46
- resolve(null);
47
- console.log('Downloading image.');
 
 
48
  } catch (err) {
49
  reject();
50
  }
@@ -114,13 +116,13 @@
114
  </script>
115
 
116
  {#if $resultImage}
117
- <div class="inline-block relative overflow-clip">
118
  <img class="image" alt="Generative Human Result" src={$resultImage} width="256" height="512" />
119
  </div>
120
  {/if}
121
 
122
  <style lang="postcss" scoped>
123
  .image {
124
- @apply max-w-none box-border z-0 border dark:border-gray-300 border-gray-500 aspect-[256/512];
125
  }
126
  </style>
 
42
  }
43
  a.href = base64Image;
44
  };
45
+ requestAnimationFrame(() => {
46
+ console.log('Downloading image.');
47
+ a.click();
48
+ resolve(null);
49
+ });
50
  } catch (err) {
51
  reject();
52
  }
 
116
  </script>
117
 
118
  {#if $resultImage}
119
+ <div class="relative overflow-clip">
120
  <img class="image" alt="Generative Human Result" src={$resultImage} width="256" height="512" />
121
  </div>
122
  {/if}
123
 
124
  <style lang="postcss" scoped>
125
  .image {
126
+ @apply box-border z-0 border dark:border-gray-300 border-gray-500 aspect-[256/512];
127
  }
128
  </style>
frontend/src/routes/index.svelte CHANGED
@@ -51,7 +51,7 @@
51
  </article>
52
  <BrushSelector />
53
  <TemplateGallery />
54
- <div class="drawings py-3">
55
  <DrawingCanvas />
56
  <!-- {#if results} -->
57
  <ResultCanvas />
@@ -74,7 +74,7 @@
74
 
75
  <style lang="postcss" scoped>
76
  .drawings {
77
- @apply grid grid-cols-1 sm:grid-cols-2 place-items-center;
78
  }
79
  button {
80
  @apply p-1 disabled:opacity-50 bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500;
 
51
  </article>
52
  <BrushSelector />
53
  <TemplateGallery />
54
+ <div class="drawings py-3 -mx-3">
55
  <DrawingCanvas />
56
  <!-- {#if results} -->
57
  <ResultCanvas />
 
74
 
75
  <style lang="postcss" scoped>
76
  .drawings {
77
+ @apply grid grid-cols-[2fr_1.5fr] sm:grid-cols-2 place-items-center;
78
  }
79
  button {
80
  @apply p-1 disabled:opacity-50 bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500;