Upload folder using huggingface_hub
Browse files
README.md
CHANGED
@@ -1,19 +1,3 @@
|
|
1 |
-
---
|
2 |
-
tags:
|
3 |
-
- gradio-custom-component
|
4 |
-
- gradio-template-Image
|
5 |
-
- bounding box
|
6 |
-
- annotator
|
7 |
-
- annotate
|
8 |
-
- boxes
|
9 |
-
title: gradio_image_annotation V0.3.0
|
10 |
-
colorFrom: yellow
|
11 |
-
colorTo: green
|
12 |
-
sdk: docker
|
13 |
-
pinned: false
|
14 |
-
license: apache-2.0
|
15 |
-
short_description: A Gradio component for image annotation
|
16 |
-
---
|
17 |
|
18 |
# `gradio_image_annotation`
|
19 |
<a href="https://pypi.org/project/gradio_image_annotation/" target="_blank"><img alt="PyPI - Version" src="https://img.shields.io/pypi/v/gradio_image_annotation"></a>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
|
2 |
# `gradio_image_annotation`
|
3 |
<a href="https://pypi.org/project/gradio_image_annotation/" target="_blank"><img alt="PyPI - Version" src="https://img.shields.io/pypi/v/gradio_image_annotation"></a>
|
src/backend/gradio_image_annotation/templates/component/index.js
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
src/frontend/shared/Canvas.svelte
CHANGED
@@ -68,6 +68,7 @@
|
|
68 |
y: 0,
|
69 |
distance: 0,
|
70 |
}
|
|
|
71 |
|
72 |
const dispatch = createEventDispatcher<{
|
73 |
change: undefined;
|
@@ -138,16 +139,19 @@
|
|
138 |
}
|
139 |
|
140 |
const getDistance = (touch1: PointerEvent, touch2: PointerEvent) => {
|
141 |
-
|
142 |
Math.pow(touch1.clientX - touch2.clientX, 2) +
|
143 |
Math.pow(touch1.clientY - touch2.clientY, 2)
|
144 |
);
|
|
|
145 |
};
|
146 |
|
147 |
function handlePointerDown(event: PointerEvent) {
|
148 |
if (!interactive) {
|
149 |
return;
|
150 |
}
|
|
|
|
|
151 |
canvas.setPointerCapture(event.pointerId);
|
152 |
pointersCache.set(event.pointerId, event);
|
153 |
|
@@ -168,8 +172,9 @@
|
|
168 |
const touch1 = pointerArray[0];
|
169 |
const touch2 = pointerArray[1];
|
170 |
const distance = getDistance(touch1, touch2);
|
171 |
-
const
|
172 |
-
const
|
|
|
173 |
|
174 |
touchScaleValues.distance = distance;
|
175 |
touchScaleValues.x = centerX;
|
@@ -237,6 +242,7 @@
|
|
237 |
return;
|
238 |
}
|
239 |
|
|
|
240 |
if (event.pointerType === "mouse") {
|
241 |
if (!handlesCursor) {
|
242 |
return;
|
@@ -275,8 +281,9 @@
|
|
275 |
const touch1 = pointerArray[0];
|
276 |
const touch2 = pointerArray[1];
|
277 |
const distance = getDistance(touch1, touch2);
|
278 |
-
const
|
279 |
-
const
|
|
|
280 |
|
281 |
const newScaleTmp = parseFloat(
|
282 |
(canvasWindow.scale * (distance / touchScaleValues.distance)).toFixed(2)
|
@@ -288,7 +295,7 @@
|
|
288 |
canvasWindow.offsetY = touchScaleValues.y - (touchScaleValues.y - canvasWindow.offsetY) * scaleDelta;
|
289 |
|
290 |
const dx = centerX - touchScaleValues.x;
|
291 |
-
|
292 |
canvasWindow.offsetX += dx;
|
293 |
canvasWindow.offsetY += dy;
|
294 |
canvasWindow.scale = newScale;
|
|
|
68 |
y: 0,
|
69 |
distance: 0,
|
70 |
}
|
71 |
+
const touchScaleDeadzone = 100;
|
72 |
|
73 |
const dispatch = createEventDispatcher<{
|
74 |
change: undefined;
|
|
|
139 |
}
|
140 |
|
141 |
const getDistance = (touch1: PointerEvent, touch2: PointerEvent) => {
|
142 |
+
const distance = Math.sqrt(
|
143 |
Math.pow(touch1.clientX - touch2.clientX, 2) +
|
144 |
Math.pow(touch1.clientY - touch2.clientY, 2)
|
145 |
);
|
146 |
+
return distance < touchScaleDeadzone ? touchScaleDeadzone : distance;
|
147 |
};
|
148 |
|
149 |
function handlePointerDown(event: PointerEvent) {
|
150 |
if (!interactive) {
|
151 |
return;
|
152 |
}
|
153 |
+
|
154 |
+
event.preventDefault();
|
155 |
canvas.setPointerCapture(event.pointerId);
|
156 |
pointersCache.set(event.pointerId, event);
|
157 |
|
|
|
172 |
const touch1 = pointerArray[0];
|
173 |
const touch2 = pointerArray[1];
|
174 |
const distance = getDistance(touch1, touch2);
|
175 |
+
const rect = canvas.getBoundingClientRect();
|
176 |
+
const centerX = (touch1.clientX + touch2.clientX) / 2 - rect.left;
|
177 |
+
const centerY = (touch1.clientY + touch2.clientY) / 2 - rect.top;
|
178 |
|
179 |
touchScaleValues.distance = distance;
|
180 |
touchScaleValues.x = centerX;
|
|
|
242 |
return;
|
243 |
}
|
244 |
|
245 |
+
event.preventDefault();
|
246 |
if (event.pointerType === "mouse") {
|
247 |
if (!handlesCursor) {
|
248 |
return;
|
|
|
281 |
const touch1 = pointerArray[0];
|
282 |
const touch2 = pointerArray[1];
|
283 |
const distance = getDistance(touch1, touch2);
|
284 |
+
const rect = canvas.getBoundingClientRect();
|
285 |
+
const centerX = (touch1.clientX + touch2.clientX) / 2 - rect.left;
|
286 |
+
const centerY = (touch1.clientY + touch2.clientY) / 2 - rect.top;
|
287 |
|
288 |
const newScaleTmp = parseFloat(
|
289 |
(canvasWindow.scale * (distance / touchScaleValues.distance)).toFixed(2)
|
|
|
295 |
canvasWindow.offsetY = touchScaleValues.y - (touchScaleValues.y - canvasWindow.offsetY) * scaleDelta;
|
296 |
|
297 |
const dx = centerX - touchScaleValues.x;
|
298 |
+
const dy = centerY - touchScaleValues.y;
|
299 |
canvasWindow.offsetX += dx;
|
300 |
canvasWindow.offsetY += dy;
|
301 |
canvasWindow.scale = newScale;
|
src/pyproject.toml
CHANGED
@@ -8,7 +8,7 @@ build-backend = "hatchling.build"
|
|
8 |
|
9 |
[project]
|
10 |
name = "gradio_image_annotation"
|
11 |
-
version = "0.3.
|
12 |
description = "A Gradio component that can be used to annotate images with bounding boxes."
|
13 |
readme = "README.md"
|
14 |
license = "MIT"
|
|
|
8 |
|
9 |
[project]
|
10 |
name = "gradio_image_annotation"
|
11 |
+
version = "0.3.1"
|
12 |
description = "A Gradio component that can be used to annotate images with bounding boxes."
|
13 |
readme = "README.md"
|
14 |
license = "MIT"
|