Public
Versions
- Open: VersionChanges from v127 to v128+7-7⦚ 132 unchanged lines ⦚// Adjust coordinates back to original scale
const adjustedCoordinates = coordinates.map(coord => [Math.round(coord[0] / tile.height * tile.originalHeight),Math.round(coord[1] / tile.width * tile.originalWidth),Math.round(coord[2] / tile.height * tile.originalHeight),Math.round(coord[3] / tile.width * tile.originalWidth)]);// Return coordinates for each tilereturn { coordinates: adjustedCoordinates, processedTile: tile }; // Renamed tile to processedTile} catch (error) {console.error('Attempt ' + attempt + ' failed: ' + error.message);⦚ 365 unchanged lines ⦚⦚ 132 unchanged lines ⦚// Adjust coordinates back to original scale// const adjustedCoordinates = coordinates.map(coord => [// Math.round(coord[0] / tile.height * tile.originalHeight),// Math.round(coord[1] / tile.width * tile.originalWidth),// Math.round(coord[2] / tile.height * tile.originalHeight),// Math.round(coord[3] / tile.width * tile.originalWidth)// ]);// Return coordinates for each tilereturn { coordinates: coordinates, processedTile: tile }; // Renamed tile to processedTile} catch (error) {console.error('Attempt ' + attempt + ' failed: ' + error.message);⦚ 365 unchanged lines ⦚ - Open: VersionChanges from v126 to v127+3-1⦚ 345 unchanged lines ⦚ctx.drawImage(image, 0, 0);
// Draw bounding boxesconst colors = ['#FF0000', '#00FF00', '#0000FF', '#FFFF00', '#FF00FF', '#00FFFF'];coordinates.forEach((box, index) => {⦚ 137 unchanged lines ⦚<input type="number" id="colsInput" value="1" min="1" max="5"><label for="delayInput">Delay between requests (ms):</label><input type="number" id="delayInput" value="5000" min="0" max="10000" step="100"></div><button id="submitBtn">Process</button>⦚ 16 unchanged lines ⦚⦚ 345 unchanged lines ⦚ctx.drawImage(image, 0, 0);console.log('wtflol',coordinates)// Draw bounding boxesconst colors = ['#FF0000', '#00FF00', '#0000FF', '#FFFF00', '#FF00FF', '#00FFFF'];coordinates.forEach((box, index) => {⦚ 137 unchanged lines ⦚<input type="number" id="colsInput" value="1" min="1" max="5"><label for="delayInput">Delay between requests (ms):</label><input type="number" id="delayInput" value="1000" min="0" max="10000" step="100"></div><button id="submitBtn">Process</button>⦚ 16 unchanged lines ⦚ - Open: VersionChanges from v125 to v126+14-6⦚ 131 unchanged lines ⦚console.log("processTileWithRetry coordinates:", coordinates)
// Return coordinates for each tilereturn { coordinates, processedTile: tile }; // Renamed tile to processedTile} catch (error) {console.error('Attempt ' + attempt + ' failed: ' + error.message);⦚ 204 unchanged lines ⦚coordinates.forEach((box, index) => {const [ymin, xmin, ymax, xmax] = box;const adjustedXmin = xmin - tile.x;const adjustedYmin = ymin - tile.y;const width = xmax - xmin;const height = ymax - ymin;ctx.strokeStyle = colors[index % colors.length];ctx.lineWidth = 2;ctx.strokeRect(adjustedXmin, adjustedYmin, width, height);});⦚ 147 unchanged lines ⦚⦚ 131 unchanged lines ⦚console.log("processTileWithRetry coordinates:", coordinates)// Adjust coordinates back to original scaleconst adjustedCoordinates = coordinates.map(coord => [Math.round(coord[0] / tile.height * tile.originalHeight),Math.round(coord[1] / tile.width * tile.originalWidth),Math.round(coord[2] / tile.height * tile.originalHeight),Math.round(coord[3] / tile.width * tile.originalWidth)]);// Return coordinates for each tilereturn { coordinates: adjustedCoordinates, processedTile: tile }; // Renamed tile to processedTile} catch (error) {console.error('Attempt ' + attempt + ' failed: ' + error.message);⦚ 204 unchanged lines ⦚coordinates.forEach((box, index) => {const [ymin, xmin, ymax, xmax] = box;const adjustedXmin = (xmin - tile.x) * (tile.width / tile.originalWidth);const adjustedYmin = (ymin - tile.y) * (tile.height / tile.originalHeight);const adjustedWidth = (xmax - xmin) * (tile.width / tile.originalWidth);const adjustedHeight = (ymax - ymin) * (tile.height / tile.originalHeight);ctx.strokeStyle = colors[index % colors.length];ctx.lineWidth = 2;ctx.strokeRect(adjustedXmin, adjustedYmin, adjustedWidth, adjustedHeight);});⦚ 147 unchanged lines ⦚ - Open: VersionChanges from v124 to v125+3-1⦚ 341 unchanged lines ⦚coordinates.forEach((box, index) => {const [ymin, xmin, ymax, xmax] = box;
const width = xmax - xmin;const height = ymax - ymin;ctx.strokeStyle = colors[index % colors.length];ctx.lineWidth = 2;ctx.strokeRect(xmin - tile.x, ymin - tile.y, width, height);});⦚ 147 unchanged lines ⦚⦚ 341 unchanged lines ⦚coordinates.forEach((box, index) => {const [ymin, xmin, ymax, xmax] = box;const adjustedXmin = xmin - tile.x;const adjustedYmin = ymin - tile.y;const width = xmax - xmin;const height = ymax - ymin;ctx.strokeStyle = colors[index % colors.length];ctx.lineWidth = 2;ctx.strokeRect(adjustedXmin, adjustedYmin, width, height);});⦚ 147 unchanged lines ⦚ - Open: VersionChanges from v123 to v124+8-8⦚ 179 unchanged lines ⦚try {const { coordinates, processedTile } = await processTileWithRetry(model, tile, promptInput.value + promptInputAdd, delayMs);
const adjustedCoordinates = coordinates.map(coord => ({ymin: coord[0] * tile.height + tile.y,xmin: coord[1] * tile.width + tile.x,ymax: coord[2] * tile.height + tile.y,xmax: coord[3] * tile.width + tile.x}));allCoordinates = allCoordinates.concat(adjustedCoordinates);⦚ 85 unchanged lines ⦚// Draw bounding boxescoordinates.forEach((box) => {const {ymin, xmin, ymax, xmax} = box;ctx.strokeStyle = '#FF0000';ctx.lineWidth = 2;⦚ 61 unchanged lines ⦚const colors = ['#FF0000', '#00FF00', '#0000FF', '#FFFF00', '#FF00FF', '#00FFFF'];coordinates.forEach((box, index) => {const { ymin, xmin, ymax, xmax } = box;const width = xmax - xmin;const height = ymax - ymin;⦚ 153 unchanged lines ⦚⦚ 179 unchanged lines ⦚try {const { coordinates, processedTile } = await processTileWithRetry(model, tile, promptInput.value + promptInputAdd, delayMs);const adjustedCoordinates = coordinates.map(coord => [coord[0] * tile.height + tile.y,coord[1] * tile.width + tile.x,coord[2] * tile.height + tile.y,coord[3] * tile.width + tile.x]);allCoordinates = allCoordinates.concat(adjustedCoordinates);⦚ 85 unchanged lines ⦚// Draw bounding boxescoordinates.forEach((box) => {const [ymin, xmin, ymax, xmax] = box;ctx.strokeStyle = '#FF0000';ctx.lineWidth = 2;⦚ 61 unchanged lines ⦚const colors = ['#FF0000', '#00FF00', '#0000FF', '#FFFF00', '#FF00FF', '#00FFFF'];coordinates.forEach((box, index) => {const [ymin, xmin, ymax, xmax] = box;const width = xmax - xmin;const height = ymax - ymin;⦚ 153 unchanged lines ⦚ - Open: VersionChanges from v122 to v123+1-1⦚ 470 unchanged lines ⦚<h1>Gemini API Image Bounding Box Visualization</h1><input type="file" id="imageInput" accept="image/*">
<textarea id="promptInput">Return bounding boxes as JSON arrays [ymin, xmin, ymax, xmax] [ymin, xmin, ymax, xmax]</textarea><div><label for="rowsInput">Rows:</label>⦚ 23 unchanged lines ⦚⦚ 470 unchanged lines ⦚<h1>Gemini API Image Bounding Box Visualization</h1><input type="file" id="imageInput" accept="image/*"><textarea id="promptInput">Return bounding boxes as JSON arrays [ymin, xmin, ymax, xmax]</textarea><div><label for="rowsInput">Rows:</label>⦚ 23 unchanged lines ⦚ - Open: VersionChanges from v121 to v122+2-2⦚ 470 unchanged lines ⦚<h1>Gemini API Image Bounding Box Visualization</h1><input type="file" id="imageInput" accept="image/*">
<textarea id="promptInput">Return bounding boxes as JSON arrays for each image of a banana image [ymin, xmin, ymax, xmax]</textarea><div><label for="rowsInput">Rows:</label><input type="number" id="rowsInput" value="1" min="1" max="5"><label for="colsInput">Columns:</label><input type="number" id="colsInput" value="2" min="1" max="5"><label for="delayInput">Delay between requests (ms):</label><input type="number" id="delayInput" value="5000" min="0" max="10000" step="100">⦚ 18 unchanged lines ⦚⦚ 470 unchanged lines ⦚<h1>Gemini API Image Bounding Box Visualization</h1><input type="file" id="imageInput" accept="image/*"><textarea id="promptInput">Return bounding boxes as JSON arrays [ymin, xmin, ymax, xmax] [ymin, xmin, ymax, xmax]</textarea><div><label for="rowsInput">Rows:</label><input type="number" id="rowsInput" value="1" min="1" max="5"><label for="colsInput">Columns:</label><input type="number" id="colsInput" value="1" min="1" max="5"><label for="delayInput">Delay between requests (ms):</label><input type="number" id="delayInput" value="5000" min="0" max="10000" step="100">⦚ 18 unchanged lines ⦚ - Open: VersionChanges from v120 to v121+51-15⦚ 179 unchanged lines ⦚try {const { coordinates, processedTile } = await processTileWithRetry(model, tile, promptInput.value + promptInputAdd, delayMs);
allCoordinates = allCoordinates.concat(coordinates.map(coord => ({ymin: coord[0] * (tile.height / tile.originalHeight), // Adjust for tile heightxmin: coord[1] * (tile.width / tile.originalWidth), // Adjust for tile widthymax: coord[2] * (tile.height / tile.originalHeight), // Adjust for tile heightxmax: coord[3] * (tile.width / tile.originalWidth) // Adjust for tile width})));// Display each tile with bounding boxesdisplayTileWithBoundingBoxes(processedTile, { coordinates });// Update progress⦚ 147 unchanged lines ⦚const colors = ['#FF0000', '#00FF00', '#0000FF', '#FFFF00', '#FF00FF', '#00FFFF'];coordinates.forEach((box, index) => {if (Array.isArray(box) && box.length === 4) {const [ymin, xmin, ymax, xmax] = box;const width = xmax - xmin;const height = ymax - ymin;ctx.strokeStyle = colors[index % colors.length];ctx.lineWidth = 2;ctx.strokeRect(xmin, ymin, width, height);}});// Append the canvas to the tiles container⦚ 109 unchanged lines ⦚⦚ 179 unchanged lines ⦚try {const { coordinates, processedTile } = await processTileWithRetry(model, tile, promptInput.value + promptInputAdd, delayMs);const adjustedCoordinates = coordinates.map(coord => ({ymin: coord[0] * tile.height + tile.y,xmin: coord[1] * tile.width + tile.x,ymax: coord[2] * tile.height + tile.y,xmax: coord[3] * tile.width + tile.x}));allCoordinates = allCoordinates.concat(adjustedCoordinates);// Display each tile with bounding boxesdisplayTileWithBoundingBoxes(processedTile, { coordinates: adjustedCoordinates });// Update progress⦚ 147 unchanged lines ⦚const colors = ['#FF0000', '#00FF00', '#0000FF', '#FFFF00', '#FF00FF', '#00FFFF'];coordinates.forEach((box, index) => {const { ymin, xmin, ymax, xmax } = box;const width = xmax - xmin;const height = ymax - ymin;ctx.strokeStyle = colors[index % colors.length];ctx.lineWidth = 2;ctx.strokeRect(xmin - tile.x, ymin - tile.y, width, height);});// Draw grid linesctx.strokeStyle = 'rgba(255, 0, 0, 0.5)';ctx.lineWidth = 1;// Vertical grid linesfor (let i = 0; i <= tile.width; i += 100) {ctx.beginPath(); - Open: Version+462-0export default async function (req: Request): Promise<Response> {const markdownJsonRegex = /```json\n([\s\S]*?)```/;const html = `<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Gemini API Image Bounding Box Visualization</title><script type="module">import { GoogleGenerativeAI } from "https://esm.run/@google/generative-ai";import { marked } from "https://esm.run/marked";function getApiKey() {let apiKey = localStorage.getItem("GEMINI_API_KEY");if (!apiKey) {apiKey = prompt("Please enter your Gemini API key:");if (apiKey) {localStorage.setItem("GEMINI_API_KEY", apiKey);}}return apiKey;}async function getGenerativeModel(params) {const API_KEY = getApiKey();const genAI = new GoogleGenerativeAI(API_KEY);return genAI.getGenerativeModel(params);}async function fileToGenerativePart(file) {return new Promise((resolve) => {const reader = new FileReader();reader.onloadend = () => resolve({inlineData: {data: reader.result.split(",")[1],
yawnxyz-geminibbox.web.val.run
Updated: October 31, 2024