ranga23127 commited on
Commit
3fb2e61
·
verified ·
1 Parent(s): 8e68ddd

Add 2 files

Browse files
Files changed (2) hide show
  1. index.html +120 -24
  2. prompts.txt +2 -1
index.html CHANGED
@@ -68,7 +68,7 @@
68
  width: 0;
69
  height: 0;
70
  border-left: 6px solid transparent;
71
- border-right: 6px solid transparent;
72
  border-top: 6px solid rgba(0, 0, 0, 0.8);
73
  bottom: -6px;
74
  left: 50%;
@@ -150,7 +150,7 @@
150
  <option value="">Select a sample...</option>
151
  <option value="https://images.unsplash.com/photo-1546069901-ba9599a7e63c?w=800">Food Sample</option>
152
  <option value="https://images.unsplash.com/photo-1526170375885-4d8ecf77b99f?w=800">Electronics Sample</option>
153
- <option value="https://images.unsplash.com/photo-1551963831-b3b1ca40c98e?w=800">Flower Sample</option>
154
  <option value="https://images.unsplash.com/photo-1489987707025-afc232f7ea0f?w=800">Clothing Sample</option>
155
  </select>
156
  </div>
@@ -286,6 +286,7 @@
286
  let currentMediaUrl = '';
287
  let currentMediaWidth = 0;
288
  let currentMediaHeight = 0;
 
289
 
290
  // Event listeners
291
  uploadBtn.addEventListener('click', () => fileInput.click());
@@ -315,6 +316,21 @@
315
  mediaType.value = currentMediaType;
316
 
317
  const url = URL.createObjectURL(file);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
318
  loadMedia(url);
319
  }
320
 
@@ -334,6 +350,20 @@
334
  currentMediaType = 'image'; // All samples are images
335
  mediaType.value = currentMediaType;
336
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
337
  loadMedia(url);
338
  }
339
 
@@ -351,6 +381,10 @@
351
 
352
  mediaElement.onload = function() {
353
  setupCanvas(mediaElement);
 
 
 
 
354
  };
355
  } else {
356
  videoElement.src = url;
@@ -368,6 +402,69 @@
368
  resultsContainer.classList.add('hidden');
369
  }
370
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
371
  // Setup canvas dimensions
372
  function setupCanvas(media) {
373
  const container = media.parentElement;
@@ -547,17 +644,16 @@
547
  searchResults.innerHTML = '';
548
  searchTags.innerHTML = '';
549
 
550
- // Generate search tags based on sample selected
551
  let tags = [];
552
- const sampleText = sampleSelect.options[sampleSelect.selectedIndex].text;
553
 
554
- if (sampleText.includes('Food')) {
555
  tags = ['food', 'meal', 'delicious', 'recipe', 'cooking', 'breakfast', 'healthy', 'nutrition'];
556
- } else if (sampleText.includes('Electronics')) {
557
  tags = ['electronics', 'camera', 'photography', 'tech', 'gadget', 'digital', 'lens', 'accessories'];
558
- } else if (sampleText.includes('Flower')) {
559
- tags = ['flower', 'floral', 'bouquet', 'garden', 'bloom', 'nature', 'plant', 'arrangement'];
560
- } else if (sampleText.includes('Clothing')) {
561
  tags = ['clothing', 'fashion', 'apparel', 'style', 'wear', 'jacket', 'outfit', 'casual'];
562
  } else {
563
  tags = ['object', 'item', 'visual', 'search', 'similar', 'product', 'shopping', 'online'];
@@ -572,7 +668,7 @@
572
  });
573
 
574
  // Generate mock results that simulate Google search results
575
- const mockResults = generateMockResults(sampleText);
576
 
577
  // Display results
578
  mockResults.forEach(result => {
@@ -633,9 +729,9 @@
633
  resultsContainer.scrollIntoView({ behavior: 'smooth' });
634
  }
635
 
636
- // Generate mock search results based on sample type
637
- function generateMockResults(sampleText) {
638
- if (sampleText.includes('Food')) {
639
  return [
640
  { url: 'https://images.unsplash.com/photo-1546069901-ba9599a7e63c?w=300', title: 'Delicious Breakfast Platter', source: 'foodnetwork.com', price: '$12.99', rating: 4.5, reviews: 128 },
641
  { url: 'https://images.unsplash.com/photo-1565958011703-44f9829ba187?w=300', title: 'Healthy Meal Prep Containers', source: 'mealprep.com', price: '$9.99', rating: 4.2, reviews: 87 },
@@ -646,7 +742,7 @@
646
  { url: 'https://images.unsplash.com/photo-1490645935967-10de6ba17061?w=300', title: 'Acai Breakfast Bowl', source: 'superfoods.com', price: '$11.49', rating: 4.9, reviews: 287 },
647
  { url: 'https://images.unsplash.com/photo-1546069901-d5bfd2cbfb1f?w=300', title: 'Colorful Salad Ingredients', source: 'saladrecipes.com', price: '$6.99', rating: 4.1, reviews: 53 }
648
  ];
649
- } else if (sampleText.includes('Electronics')) {
650
  return [
651
  { url: 'https://images.unsplash.com/photo-1526170375885-4d8ecf77b99f?w=300', title: 'Vintage Camera Collection', source: 'vintagecameras.com', price: '$249.99', rating: 4.8, reviews: 342 },
652
  { url: 'https://images.unsplash.com/photo-1516035069371-29a1b244cc32?w=300', title: '4K Digital Camera', source: 'techgadgets.com', price: '$399.99', rating: 4.6, reviews: 215 },
@@ -657,18 +753,18 @@
657
  { url: 'https://images.unsplash.com/photo-1516035069371-29a1b244cc32?w=300', title: 'Polaroid Instant Camera', source: 'instantphotos.com', price: '$129.99', rating: 4.2, reviews: 187 },
658
  { url: 'https://images.unsplash.com/photo-1516035069371-29a1b244cc32?w=300', title: 'Film Camera Starter Kit', source: 'filmphotography.com', price: '$199.99', rating: 4.7, reviews: 156 }
659
  ];
660
- } else if (sampleText.includes('Flower')) {
661
  return [
662
- { url: 'https://images.unsplash.com/photo-1551963831-b3b1ca40c98e?w=300', title: 'Fresh Cut Flowers Bouquet', source: 'florist.com', price: '$29.99', rating: 4.8, reviews: 432 },
663
- { url: 'https://images.unsplash.com/photo-1521012012373-6a85fade14b3?w=300', title: 'Rose Flower Arrangement', source: 'rosegarden.com', price: '$39.99', rating: 4.9, reviews: 387 },
664
- { url: 'https://images.unsplash.com/photo-1490750967868-88aa4486c946?w=300', title: 'Sunflower Bouquet', source: 'sunflowershop.com', price: '$24.99', rating: 4.7, reviews: 215 },
665
- { url: 'https://images.unsplash.com/photo-1455659817273-68adca893fe3?w=300', title: 'Tulip Flower Bunch', source: 'tulipfarm.com', price: '$19.99', rating: 4.6, reviews: 176 },
666
- { url: 'https://images.unsplash.com/photo-1455659817273-68adca893fe3?w=300', title: 'Orchid Plant in Pot', source: 'orchidlovers.com', price: '$34.99', rating: 4.8, reviews: 243 },
667
- { url: 'https://images.unsplash.com/photo-1455659817273-68adca893fe3?w=300', title: 'Lily Flower Arrangement', source: 'lilygarden.com', price: '$27.99', rating: 4.5, reviews: 128 },
668
- { url: 'https://images.unsplash.com/photo-1455659817273-68adca893fe3?w=300', title: 'Wildflower Seed Mix', source: 'gardensupply.com', price: '$14.99', rating: 4.4, reviews: 342 },
669
- { url: 'https://images.unsplash.com/photo-1455659817273-68adca893fe3?w=300', title: 'Daisy Flower Crown', source: 'flowercrowns.com', price: '$22.99', rating: 4.7, reviews: 187 }
670
  ];
671
- } else if (sampleText.includes('Clothing')) {
672
  return [
673
  { url: 'https://images.unsplash.com/photo-1489987707025-afc232f7ea0f?w=300', title: 'Denim Jacket - Blue', source: 'denimwear.com', price: '$59.99', rating: 4.6, reviews: 342 },
674
  { url: 'https://images.unsplash.com/photo-1529374255404-311a2a4f1fd9?w=300', title: 'Casual T-Shirt - White', source: 'basicshirts.com', price: '$19.99', rating: 4.3, reviews: 215 },
 
68
  width: 0;
69
  height: 0;
70
  border-left: 6px solid transparent;
71
+ border-right: 6px solid solid transparent;
72
  border-top: 6px solid rgba(0, 0, 0, 0.8);
73
  bottom: -6px;
74
  left: 50%;
 
150
  <option value="">Select a sample...</option>
151
  <option value="https://images.unsplash.com/photo-1546069901-ba9599a7e63c?w=800">Food Sample</option>
152
  <option value="https://images.unsplash.com/photo-1526170375885-4d8ecf77b99f?w=800">Electronics Sample</option>
153
+ <option value="https://images.unsplash.com/photo-1524805444758-089113d48a6d?w=800">Watch Sample</option>
154
  <option value="https://images.unsplash.com/photo-1489987707025-afc232f7ea0f?w=800">Clothing Sample</option>
155
  </select>
156
  </div>
 
286
  let currentMediaUrl = '';
287
  let currentMediaWidth = 0;
288
  let currentMediaHeight = 0;
289
+ let currentMediaCategory = '';
290
 
291
  // Event listeners
292
  uploadBtn.addEventListener('click', () => fileInput.click());
 
316
  mediaType.value = currentMediaType;
317
 
318
  const url = URL.createObjectURL(file);
319
+
320
+ // Try to detect category from filename if possible
321
+ const fileName = file.name.toLowerCase();
322
+ if (fileName.includes('watch') || fileName.includes('time') || fileName.includes('clock')) {
323
+ currentMediaCategory = 'watch';
324
+ } else if (fileName.includes('food') || fileName.includes('meal') || fileName.includes('dish')) {
325
+ currentMediaCategory = 'food';
326
+ } else if (fileName.includes('cloth') || fileName.includes('shirt') || fileName.includes('jacket')) {
327
+ currentMediaCategory = 'clothing';
328
+ } else if (fileName.includes('electronic') || fileName.includes('camera') || fileName.includes('gadget')) {
329
+ currentMediaCategory = 'electronics';
330
+ } else {
331
+ currentMediaCategory = ''; // Will be detected from visual analysis
332
+ }
333
+
334
  loadMedia(url);
335
  }
336
 
 
350
  currentMediaType = 'image'; // All samples are images
351
  mediaType.value = currentMediaType;
352
 
353
+ // Set category based on sample selection
354
+ const sampleText = sampleSelect.options[sampleSelect.selectedIndex].text;
355
+ if (sampleText.includes('Food')) {
356
+ currentMediaCategory = 'food';
357
+ } else if (sampleText.includes('Electronics')) {
358
+ currentMediaCategory = 'electronics';
359
+ } else if (sampleText.includes('Watch')) {
360
+ currentMediaCategory = 'watch';
361
+ } else if (sampleText.includes('Clothing')) {
362
+ currentMediaCategory = 'clothing';
363
+ } else {
364
+ currentMediaCategory = '';
365
+ }
366
+
367
  loadMedia(url);
368
  }
369
 
 
381
 
382
  mediaElement.onload = function() {
383
  setupCanvas(mediaElement);
384
+ // If category wasn't set, try to detect from image
385
+ if (!currentMediaCategory) {
386
+ detectCategoryFromImage(mediaElement);
387
+ }
388
  };
389
  } else {
390
  videoElement.src = url;
 
402
  resultsContainer.classList.add('hidden');
403
  }
404
 
405
+ // Simple image analysis to detect category
406
+ function detectCategoryFromImage(img) {
407
+ // Create a temporary canvas to analyze the image
408
+ const tempCanvas = document.createElement('canvas');
409
+ const tempCtx = tempCanvas.getContext('2d');
410
+ tempCanvas.width = img.naturalWidth;
411
+ tempCanvas.height = img.naturalHeight;
412
+ tempCtx.drawImage(img, 0, 0);
413
+
414
+ // Get image data
415
+ const imageData = tempCtx.getImageData(0, 0, tempCanvas.width, tempCanvas.height);
416
+ const data = imageData.data;
417
+
418
+ // Simple analysis (this is very basic - in a real app you'd use ML)
419
+ let colorCount = 0;
420
+ let darkCount = 0;
421
+ let brightCount = 0;
422
+ let redCount = 0;
423
+ let blueCount = 0;
424
+ let greenCount = 0;
425
+
426
+ // Sample some pixels (every 10th pixel for performance)
427
+ for (let i = 0; i < data.length; i += 40) {
428
+ const r = data[i];
429
+ const g = data[i + 1];
430
+ const b = data[i + 2];
431
+ const a = data[i + 3];
432
+
433
+ if (a > 0) {
434
+ colorCount++;
435
+ const brightness = (r + g + b) / 3;
436
+
437
+ if (brightness < 85) darkCount++;
438
+ if (brightness > 170) brightCount++;
439
+
440
+ if (r > g * 1.5 && r > b * 1.5) redCount++;
441
+ if (g > r * 1.5 && g > b * 1.5) greenCount++;
442
+ if (b > r * 1.5 && b > g * 1.5) blueCount++;
443
+ }
444
+ }
445
+
446
+ // Make a guess based on colors
447
+ const totalPixels = colorCount;
448
+ const redRatio = redCount / totalPixels;
449
+ const greenRatio = greenCount / totalPixels;
450
+ const blueRatio = blueCount / totalPixels;
451
+ const brightRatio = brightCount / totalPixels;
452
+ const darkRatio = darkCount / totalPixels;
453
+
454
+ // Very basic heuristics
455
+ if (greenRatio > 0.3 && brightRatio > 0.5) {
456
+ currentMediaCategory = 'food'; // Likely food with lots of greens/bright colors
457
+ } else if (darkRatio > 0.7) {
458
+ currentMediaCategory = 'electronics'; // Likely dark background electronics
459
+ } else if (blueRatio > 0.3 && brightRatio > 0.4) {
460
+ currentMediaCategory = 'clothing'; // Likely clothing with blue tones
461
+ } else if (brightRatio > 0.6 && redRatio < 0.2 && greenRatio < 0.2) {
462
+ currentMediaCategory = 'watch'; // Likely watch with metallic/silver tones
463
+ } else {
464
+ currentMediaCategory = ''; // Unknown
465
+ }
466
+ }
467
+
468
  // Setup canvas dimensions
469
  function setupCanvas(media) {
470
  const container = media.parentElement;
 
644
  searchResults.innerHTML = '';
645
  searchTags.innerHTML = '';
646
 
647
+ // Generate search tags based on detected category
648
  let tags = [];
 
649
 
650
+ if (currentMediaCategory === 'food') {
651
  tags = ['food', 'meal', 'delicious', 'recipe', 'cooking', 'breakfast', 'healthy', 'nutrition'];
652
+ } else if (currentMediaCategory === 'electronics') {
653
  tags = ['electronics', 'camera', 'photography', 'tech', 'gadget', 'digital', 'lens', 'accessories'];
654
+ } else if (currentMediaCategory === 'watch') {
655
+ tags = ['watch', 'timepiece', 'wristwatch', 'luxury', 'smartwatch', 'analog', 'digital', 'chronograph'];
656
+ } else if (currentMediaCategory === 'clothing') {
657
  tags = ['clothing', 'fashion', 'apparel', 'style', 'wear', 'jacket', 'outfit', 'casual'];
658
  } else {
659
  tags = ['object', 'item', 'visual', 'search', 'similar', 'product', 'shopping', 'online'];
 
668
  });
669
 
670
  // Generate mock results that simulate Google search results
671
+ const mockResults = generateMockResults();
672
 
673
  // Display results
674
  mockResults.forEach(result => {
 
729
  resultsContainer.scrollIntoView({ behavior: 'smooth' });
730
  }
731
 
732
+ // Generate mock search results based on detected category
733
+ function generateMockResults() {
734
+ if (currentMediaCategory === 'food') {
735
  return [
736
  { url: 'https://images.unsplash.com/photo-1546069901-ba9599a7e63c?w=300', title: 'Delicious Breakfast Platter', source: 'foodnetwork.com', price: '$12.99', rating: 4.5, reviews: 128 },
737
  { url: 'https://images.unsplash.com/photo-1565958011703-44f9829ba187?w=300', title: 'Healthy Meal Prep Containers', source: 'mealprep.com', price: '$9.99', rating: 4.2, reviews: 87 },
 
742
  { url: 'https://images.unsplash.com/photo-1490645935967-10de6ba17061?w=300', title: 'Acai Breakfast Bowl', source: 'superfoods.com', price: '$11.49', rating: 4.9, reviews: 287 },
743
  { url: 'https://images.unsplash.com/photo-1546069901-d5bfd2cbfb1f?w=300', title: 'Colorful Salad Ingredients', source: 'saladrecipes.com', price: '$6.99', rating: 4.1, reviews: 53 }
744
  ];
745
+ } else if (currentMediaCategory === 'electronics') {
746
  return [
747
  { url: 'https://images.unsplash.com/photo-1526170375885-4d8ecf77b99f?w=300', title: 'Vintage Camera Collection', source: 'vintagecameras.com', price: '$249.99', rating: 4.8, reviews: 342 },
748
  { url: 'https://images.unsplash.com/photo-1516035069371-29a1b244cc32?w=300', title: '4K Digital Camera', source: 'techgadgets.com', price: '$399.99', rating: 4.6, reviews: 215 },
 
753
  { url: 'https://images.unsplash.com/photo-1516035069371-29a1b244cc32?w=300', title: 'Polaroid Instant Camera', source: 'instantphotos.com', price: '$129.99', rating: 4.2, reviews: 187 },
754
  { url: 'https://images.unsplash.com/photo-1516035069371-29a1b244cc32?w=300', title: 'Film Camera Starter Kit', source: 'filmphotography.com', price: '$199.99', rating: 4.7, reviews: 156 }
755
  ];
756
+ } else if (currentMediaCategory === 'watch') {
757
  return [
758
+ { url: 'https://images.unsplash.com/photo-1524805444758-089113d48a6d?w=300', title: 'Luxury Chronograph Watch', source: 'timepieces.com', price: '$499.99', rating: 4.7, reviews: 287 },
759
+ { url: 'https://images.unsplash.com/photo-1523170335258-f5ed1181a481?w=300', title: 'Smart Watch with Fitness Tracker', source: 'smartgadgets.com', price: '$199.99', rating: 4.5, reviews: 432 },
760
+ { url: 'https://images.unsplash.com/photo-1557531365-e8b3c5c870a7?w=300', title: 'Classic Analog Watch', source: 'classictime.com', price: '$149.99', rating: 4.8, reviews: 156 },
761
+ { url: 'https://images.unsplash.com/photo-1542496658-e33a6d0d50b6?w=300', title: 'Diving Watch Waterproof', source: 'divegear.com', price: '$299.99', rating: 4.6, reviews: 187 },
762
+ { url: 'https://images.unsplash.com/photo-1557531365-e8b3c5c870a7?w=300', title: 'Minimalist Watch - Silver', source: 'minimaldesign.com', price: '$129.99', rating: 4.4, reviews: 92 },
763
+ { url: 'https://images.unsplash.com/photo-1542496658-e33a6d0d50b6?w=300', title: 'Sports Watch with GPS', source: 'sportstech.com', price: '$249.99', rating: 4.3, reviews: 215 },
764
+ { url: 'https://images.unsplash.com/photo-1557531365-e8b3c5c870a7?w=300', title: 'Gold Plated Dress Watch', source: 'luxurytime.com', price: '$399.99', rating: 4.7, reviews: 176 },
765
+ { url: 'https://images.unsplash.com/photo-1542496658-e33a6d0d50b6?w=300', title: 'Digital Watch with Alarm', source: 'basictime.com', price: '$49.99', rating: 4.1, reviews: 128 }
766
  ];
767
+ } else if (currentMediaCategory === 'clothing') {
768
  return [
769
  { url: 'https://images.unsplash.com/photo-1489987707025-afc232f7ea0f?w=300', title: 'Denim Jacket - Blue', source: 'denimwear.com', price: '$59.99', rating: 4.6, reviews: 342 },
770
  { url: 'https://images.unsplash.com/photo-1529374255404-311a2a4f1fd9?w=300', title: 'Casual T-Shirt - White', source: 'basicshirts.com', price: '$19.99', rating: 4.3, reviews: 215 },
prompts.txt CHANGED
@@ -3,4 +3,5 @@ circle is not there
3
  This functionality can be achieved using a combination of image/video processing libraries (like OpenCV) and a search engine API (like Google Images or Google Lens). The user would interact with an application that allows them to draw a circle on an image or video frame, and then the application would: 1. Extract the region within the circle: Use image processing techniques to isolate the region of the image or video frame defined by the circle. 2. Process the image/video: Potentially use techniques like object detection, image recognition, or feature extraction to create a representation of the region within the circle. 3. Make a search query: Use a search engine API to search for similar results based on the processed region. 4. Display the search results: The application would then display the search results to the user, potentially within the same application or by navigating to the search engine's website. Here's a breakdown of how the application could work: 1. Drawing and Region Extraction: The application would use a UI library (like Flutter, React, or a native UI library) to display the image or video frame. A drawing tool would allow the user to draw a circle on the image or video frame. The application would then use image processing libraries like OpenCV (in Python, Java, or C++) to extract the region within the circle. This involves determining the circle's center and radius and cropping or masking the image to isolate that area. 2. Processing the Image/Video: Object Detection/Recognition: If the goal is to find similar objects, you'd use an object detection model (like TensorFlow or PyTorch with a pre-trained model) to identify the objects within the extracted region. Feature Extraction: If the goal is to find visually similar images, you'd use techniques like feature extraction (e.g., using a CNN) to create a vector representation of the region. 3. Search Query: The application would use a search engine API (like Google Image Search API, or Google Lens API) to search for similar results. Based on the processed region, the API would be queried with a description (e.g., "objects detected" or "image features"). 4. Displaying Results: The search results would be displayed within the application, or the user would be navigated to the search engine's website to see the results.
4
  here the circle is not showing and i dont how to draw to search in google
5
  circle is there but gooogle api is not there to run here. make
6
- flower sample is wrongly like food appearing. cloths sample are not showing. change these things, its not predicting correctly or not detecting so see and make correctly
 
 
3
  This functionality can be achieved using a combination of image/video processing libraries (like OpenCV) and a search engine API (like Google Images or Google Lens). The user would interact with an application that allows them to draw a circle on an image or video frame, and then the application would: 1. Extract the region within the circle: Use image processing techniques to isolate the region of the image or video frame defined by the circle. 2. Process the image/video: Potentially use techniques like object detection, image recognition, or feature extraction to create a representation of the region within the circle. 3. Make a search query: Use a search engine API to search for similar results based on the processed region. 4. Display the search results: The application would then display the search results to the user, potentially within the same application or by navigating to the search engine's website. Here's a breakdown of how the application could work: 1. Drawing and Region Extraction: The application would use a UI library (like Flutter, React, or a native UI library) to display the image or video frame. A drawing tool would allow the user to draw a circle on the image or video frame. The application would then use image processing libraries like OpenCV (in Python, Java, or C++) to extract the region within the circle. This involves determining the circle's center and radius and cropping or masking the image to isolate that area. 2. Processing the Image/Video: Object Detection/Recognition: If the goal is to find similar objects, you'd use an object detection model (like TensorFlow or PyTorch with a pre-trained model) to identify the objects within the extracted region. Feature Extraction: If the goal is to find visually similar images, you'd use techniques like feature extraction (e.g., using a CNN) to create a vector representation of the region. 3. Search Query: The application would use a search engine API (like Google Image Search API, or Google Lens API) to search for similar results. Based on the processed region, the API would be queried with a description (e.g., "objects detected" or "image features"). 4. Displaying Results: The search results would be displayed within the application, or the user would be navigated to the search engine's website to see the results.
4
  here the circle is not showing and i dont how to draw to search in google
5
  circle is there but gooogle api is not there to run here. make
6
+ flower sample is wrongly like food appearing. cloths sample are not showing. change these things, its not predicting correctly or not detecting so see and make correctly
7
+ properly its not working so can you please i am giving a watch upload but its showing food related.