Yango1 commited on
Commit
e94413f
·
verified ·
1 Parent(s): 67320ab

Page Design: 1. Page Background: High-definition farm image (featuring straw, green crops, etc.) 2. A button displaying “Upload Crop Images” in both Chinese and English is positioned at the center of the upper portion of the page. 3. In the remaining blank areas of the page, I require 18 floating circles of varying sizes. These circles will be used to insert my local images. Note that these floating circles should have some shadow effects for aesthetic purposes. When the mouse hovers over a floating circle, a box should appear displaying the corresponding pest or disease type. Functional Design: 1. A button is positioned at the center of the upper part of the page. Button function: Clicking the button opens a dialog box to select crop photos from the local computer. After confirming the selection, the photos are uploaded to our model for processing, which outputs the pest or disease type of the crops. - Initial Deployment

Browse files
Files changed (2) hide show
  1. README.md +7 -5
  2. index.html +331 -19
README.md CHANGED
@@ -1,10 +1,12 @@
1
  ---
2
- title: Https Huggingface Co Spaces Yango1 Crops
3
- emoji: 👁
4
- colorFrom: pink
5
- colorTo: red
6
  sdk: static
7
  pinned: false
 
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: https-huggingface-co-spaces-yango1-crops
3
+ emoji: 🐳
4
+ colorFrom: green
5
+ colorTo: pink
6
  sdk: static
7
  pinned: false
8
+ tags:
9
+ - deepsite
10
  ---
11
 
12
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
index.html CHANGED
@@ -1,19 +1,331 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Crop Disease Detection</title>
7
+ <script src="https://cdn.tailwindcss.com"></script>
8
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
9
+ <style>
10
+ body {
11
+ background-image: url('https://images.unsplash.com/photo-1500382017468-9049fed747ef?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=2070&q=80');
12
+ background-size: cover;
13
+ background-position: center;
14
+ background-attachment: fixed;
15
+ min-height: 100vh;
16
+ position: relative;
17
+ overflow-x: hidden;
18
+ }
19
+
20
+ .circle {
21
+ position: absolute;
22
+ border-radius: 50%;
23
+ background-color: rgba(255, 255, 255, 0.8);
24
+ box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
25
+ transition: all 0.3s ease;
26
+ display: flex;
27
+ align-items: center;
28
+ justify-content: center;
29
+ overflow: hidden;
30
+ cursor: pointer;
31
+ }
32
+
33
+ .circle:hover {
34
+ transform: scale(1.1);
35
+ box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
36
+ }
37
+
38
+ .circle img {
39
+ width: 100%;
40
+ height: 100%;
41
+ object-fit: cover;
42
+ }
43
+
44
+ .tooltip {
45
+ position: absolute;
46
+ bottom: -40px;
47
+ left: 50%;
48
+ transform: translateX(-50%);
49
+ background-color: rgba(0, 0, 0, 0.8);
50
+ color: white;
51
+ padding: 5px 10px;
52
+ border-radius: 5px;
53
+ font-size: 12px;
54
+ white-space: nowrap;
55
+ opacity: 0;
56
+ transition: opacity 0.3s;
57
+ pointer-events: none;
58
+ }
59
+
60
+ .circle:hover .tooltip {
61
+ opacity: 1;
62
+ }
63
+
64
+ .modal {
65
+ transition: opacity 0.3s ease;
66
+ }
67
+
68
+ .modal-overlay {
69
+ background-color: rgba(0, 0, 0, 0.5);
70
+ }
71
+
72
+ @keyframes float {
73
+ 0% { transform: translateY(0px); }
74
+ 50% { transform: translateY(-10px); }
75
+ 100% { transform: translateY(0px); }
76
+ }
77
+
78
+ .floating {
79
+ animation: float 4s ease-in-out infinite;
80
+ }
81
+
82
+ .floating:nth-child(2n) {
83
+ animation-delay: 0.5s;
84
+ }
85
+
86
+ .floating:nth-child(3n) {
87
+ animation-delay: 1s;
88
+ }
89
+ </style>
90
+ </head>
91
+ <body class="font-sans">
92
+ <!-- Main Content -->
93
+ <div class="container mx-auto px-4 py-8 relative z-10">
94
+ <!-- Upload Button -->
95
+ <div class="flex justify-center mt-8 md:mt-16">
96
+ <button id="uploadBtn" class="bg-green-600 hover:bg-green-700 text-white font-bold py-4 px-8 rounded-full shadow-lg transition duration-300 transform hover:scale-105 flex items-center">
97
+ <i class="fas fa-cloud-upload-alt text-xl mr-3"></i>
98
+ <span>
99
+ <span class="block">Upload Crop Images</span>
100
+ <span class="block text-sm font-normal">上传作物图片</span>
101
+ </span>
102
+ </button>
103
+ </div>
104
+
105
+ <!-- Hidden File Input -->
106
+ <input type="file" id="fileInput" class="hidden" accept="image/*" multiple>
107
+ </div>
108
+
109
+ <!-- Floating Circles Container -->
110
+ <div id="circlesContainer" class="absolute inset-0 overflow-hidden pointer-events-none">
111
+ <!-- Circles will be dynamically added here -->
112
+ </div>
113
+
114
+ <!-- Modal Dialog -->
115
+ <div id="uploadModal" class="fixed inset-0 flex items-center justify-center z-50 modal opacity-0 pointer-events-none transition-opacity">
116
+ <div class="modal-overlay absolute inset-0"></div>
117
+ <div class="bg-white rounded-lg shadow-xl max-w-md w-full mx-4 relative z-10 p-6">
118
+ <div class="flex justify-between items-center mb-4">
119
+ <h3 class="text-xl font-bold text-gray-800">Upload Images</h3>
120
+ <button id="closeModal" class="text-gray-500 hover:text-gray-700">
121
+ <i class="fas fa-times"></i>
122
+ </button>
123
+ </div>
124
+ <div class="mb-4">
125
+ <p class="text-gray-600">Please select crop images to analyze for pests and diseases.</p>
126
+ </div>
127
+ <div class="flex justify-end space-x-3">
128
+ <button id="cancelUpload" class="px-4 py-2 border border-gray-300 rounded-md text-gray-700 hover:bg-gray-50">Cancel</button>
129
+ <button id="confirmUpload" class="px-4 py-2 bg-green-600 text-white rounded-md hover:bg-green-700">Upload & Analyze</button>
130
+ </div>
131
+ </div>
132
+ </div>
133
+
134
+ <!-- Processing Modal -->
135
+ <div id="processingModal" class="fixed inset-0 flex items-center justify-center z-50 hidden">
136
+ <div class="modal-overlay absolute inset-0"></div>
137
+ <div class="bg-white rounded-lg shadow-xl max-w-md w-full mx-4 relative z-10 p-6">
138
+ <div class="flex flex-col items-center">
139
+ <div class="animate-spin rounded-full h-12 w-12 border-t-2 border-b-2 border-green-600 mb-4"></div>
140
+ <h3 class="text-xl font-bold text-gray-800 mb-2">Processing Images</h3>
141
+ <p class="text-gray-600 text-center">Analyzing your crop images for pests and diseases. This may take a moment...</p>
142
+ </div>
143
+ </div>
144
+ </div>
145
+
146
+ <script>
147
+ document.addEventListener('DOMContentLoaded', function() {
148
+ // Elements
149
+ const uploadBtn = document.getElementById('uploadBtn');
150
+ const fileInput = document.getElementById('fileInput');
151
+ const uploadModal = document.getElementById('uploadModal');
152
+ const closeModal = document.getElementById('closeModal');
153
+ const cancelUpload = document.getElementById('cancelUpload');
154
+ const confirmUpload = document.getElementById('confirmUpload');
155
+ const processingModal = document.getElementById('processingModal');
156
+ const circlesContainer = document.getElementById('circlesContainer');
157
+
158
+ // Pest and disease types (for tooltips)
159
+ const pestTypes = [
160
+ "Aphids (蚜虫)", "Whiteflies (白粉虱)", "Spider Mites (红蜘蛛)",
161
+ "Thrips (蓟马)", "Leaf Miners (潜叶蝇)", "Mealybugs (粉蚧)",
162
+ "Scale Insects (介壳虫)", "Caterpillars (毛虫)", "Beetles (甲虫)",
163
+ "Powdery Mildew (白粉病)", "Downy Mildew (霜霉病)", "Rust (锈病)",
164
+ "Blight (枯萎病)", "Leaf Spot (叶斑病)", "Root Rot (根腐病)",
165
+ "Wilt (萎蔫病)", "Mosaic Virus (花叶病毒)", "Bacterial Spot (细菌性斑点病)"
166
+ ];
167
+
168
+ // Create floating circles
169
+ function createCircles() {
170
+ const sizes = [60, 70, 80, 90, 100];
171
+ const colors = [
172
+ 'bg-red-100', 'bg-blue-100', 'bg-green-100', 'bg-yellow-100',
173
+ 'bg-purple-100', 'bg-pink-100', 'bg-indigo-100', 'bg-teal-100'
174
+ ];
175
+
176
+ for (let i = 0; i < 18; i++) {
177
+ const circle = document.createElement('div');
178
+ const size = sizes[Math.floor(Math.random() * sizes.length)];
179
+ const color = colors[Math.floor(Math.random() * colors.length)];
180
+ const left = Math.random() * 90;
181
+ const top = Math.random() * 80 + 10; // Avoid top 10%
182
+
183
+ circle.className = `circle floating ${color} pointer-events-auto`;
184
+ circle.style.width = `${size}px`;
185
+ circle.style.height = `${size}px`;
186
+ circle.style.left = `${left}%`;
187
+ circle.style.top = `${top}%`;
188
+
189
+ // Add tooltip
190
+ const tooltip = document.createElement('div');
191
+ tooltip.className = 'tooltip';
192
+ tooltip.textContent = pestTypes[i];
193
+ circle.appendChild(tooltip);
194
+
195
+ // Add placeholder icon
196
+ const icon = document.createElement('i');
197
+ const icons = [
198
+ 'fa-bug', 'fa-leaf', 'fa-spider', 'fa-bacteria',
199
+ 'fa-virus', 'fa-seedling', 'fa-tree', 'fa-wheat-awn'
200
+ ];
201
+ icon.className = `fas ${icons[Math.floor(Math.random() * icons.length)]} text-2xl text-gray-700`;
202
+ circle.appendChild(icon);
203
+
204
+ circlesContainer.appendChild(circle);
205
+
206
+ // Make circles draggable
207
+ makeDraggable(circle);
208
+ }
209
+ }
210
+
211
+ // Make elements draggable
212
+ function makeDraggable(element) {
213
+ let pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0;
214
+
215
+ element.onmousedown = dragMouseDown;
216
+
217
+ function dragMouseDown(e) {
218
+ e = e || window.event;
219
+ e.preventDefault();
220
+ // get the mouse cursor position at startup:
221
+ pos3 = e.clientX;
222
+ pos4 = e.clientY;
223
+ document.onmouseup = closeDragElement;
224
+ // call a function whenever the cursor moves:
225
+ document.onmousemove = elementDrag;
226
+ }
227
+
228
+ function elementDrag(e) {
229
+ e = e || window.event;
230
+ e.preventDefault();
231
+ // calculate the new cursor position:
232
+ pos1 = pos3 - e.clientX;
233
+ pos2 = pos4 - e.clientY;
234
+ pos3 = e.clientX;
235
+ pos4 = e.clientY;
236
+ // set the element's new position:
237
+ element.style.top = (element.offsetTop - pos2) + "px";
238
+ element.style.left = (element.offsetLeft - pos1) + "px";
239
+ }
240
+
241
+ function closeDragElement() {
242
+ // stop moving when mouse button is released:
243
+ document.onmouseup = null;
244
+ document.onmousemove = null;
245
+ }
246
+ }
247
+
248
+ // Show upload modal
249
+ uploadBtn.addEventListener('click', () => {
250
+ fileInput.click();
251
+ });
252
+
253
+ // File input change handler
254
+ fileInput.addEventListener('change', () => {
255
+ if (fileInput.files.length > 0) {
256
+ showModal();
257
+ }
258
+ });
259
+
260
+ // Show modal function
261
+ function showModal() {
262
+ uploadModal.classList.remove('opacity-0', 'pointer-events-none');
263
+ uploadModal.classList.add('opacity-100', 'pointer-events-auto');
264
+ }
265
+
266
+ // Hide modal function
267
+ function hideModal() {
268
+ uploadModal.classList.remove('opacity-100', 'pointer-events-auto');
269
+ uploadModal.classList.add('opacity-0', 'pointer-events-none');
270
+ fileInput.value = ''; // Reset file input
271
+ }
272
+
273
+ // Close modal buttons
274
+ closeModal.addEventListener('click', hideModal);
275
+ cancelUpload.addEventListener('click', hideModal);
276
+
277
+ // Confirm upload
278
+ confirmUpload.addEventListener('click', () => {
279
+ hideModal();
280
+ processingModal.classList.remove('hidden');
281
+
282
+ // Simulate processing delay
283
+ setTimeout(() => {
284
+ processingModal.classList.add('hidden');
285
+
286
+ // Here you would normally send the images to your model
287
+ // For demo purposes, we'll just show an alert
288
+ alert('Analysis complete! The results have been added to the floating circles.');
289
+
290
+ // Update some circles with example results
291
+ updateCirclesWithResults();
292
+ }, 3000);
293
+ });
294
+
295
+ // Function to update circles with example results
296
+ function updateCirclesWithResults() {
297
+ const circles = document.querySelectorAll('.circle');
298
+ const exampleImages = [
299
+ 'https://images.unsplash.com/photo-1596541223131-891a3a5754a3?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=2070&q=80',
300
+ 'https://images.unsplash.com/photo-1518492104633-130d0b9796a7?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=2070&q=80',
301
+ 'https://images.unsplash.com/photo-1586771107445-d3ca888129ce?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=2070&q=80'
302
+ ];
303
+
304
+ // Update first 3 circles with example images
305
+ for (let i = 0; i < 3 && i < circles.length; i++) {
306
+ const circle = circles[i];
307
+ // Remove icon
308
+ if (circle.querySelector('i')) {
309
+ circle.querySelector('i').remove();
310
+ }
311
+
312
+ // Add image
313
+ const img = document.createElement('img');
314
+ img.src = exampleImages[i];
315
+ img.alt = 'Detected pest or disease';
316
+ circle.appendChild(img);
317
+
318
+ // Update tooltip with confidence level
319
+ if (circle.querySelector('.tooltip')) {
320
+ circle.querySelector('.tooltip').textContent =
321
+ `${pestTypes[i]} (${Math.floor(Math.random() * 30) + 70}% confidence)`;
322
+ }
323
+ }
324
+ }
325
+
326
+ // Initialize circles
327
+ createCircles();
328
+ });
329
+ </script>
330
+ <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=Yango1/https-huggingface-co-spaces-yango1-crops" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
331
+ </html>