Spaces:
Sleeping
Sleeping
Commit Β·
fb14bd4
1
Parent(s): dfc173e
Deploy flower classifier to Hugging Face Space with Git LFS
Browse filesFiles changed (20)
- .gitattributesAdded+1
- .gitignore+2-1
- README.md+140-1
- app.pyAdded+198
- flower_classifier.pthAdded+3
- gradio_app.pyAdded+84
- model.pyAdded+275
- predict.pyAdded+57
- requirements.txtAdded+5
- run_app.batAdded+14
- static/app.jsAdded+316
- static/samples/bellflower.jpgAdded
- static/samples/daisy.jpgAdded
- static/samples/dandelion.jpgAdded
- static/samples/lotus.jpgAdded
- static/samples/rose.jpgAdded
- static/samples/sunflower.jpgAdded
- static/samples/tulip.jpgAdded
- static/style.cssAdded+1102
- templates/index.htmlAdded+321
1*.pth filter=lfs diff=lfs merge=lfs -text7 unmodified lines8910117 unmodified lines.ipynb_checkpoints/flower-recognition-cnn-keras.ipynb7 unmodified lines891011127 unmodified lines.ipynb_checkpoints/flower-recognition-cnn-keras.ipynbhf_space/
123456---## Why Switch from an MLP to a CNN? (Engineering Post-Mortem)After training our two-layer NumPy Multilayer Perceptron (MLP) for 7,000 iterations and achieving ~90% training accuracy, empirical evaluation on unseen test images exposed a severe generalization bottleneck: real-world accuracy dropped to **40% (4/10)**.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145---title: ScratchNet Flower Classifieremoji: πͺ·colorFrom: greencolorTo: pinksdk: gradiosdk_version: 6.30.0app_file: gradio_app.pypinned: false---# πͺ· ScratchNet β 7-Class Flower Image Classifier & Web AppAn end-to-end Deep Learning computer vision project that classifies flower images across **7 distinct botanical categories** using a custom PyTorch Convolutional Neural Network (CNN). Includes an interactive, modern web application (FastAPI), a command-line interface (CLI), a Gradio interface, and a REST API.---## πΊ Detected Flower CategoriesThe trained model (`flower_classifier.pth`) detects the following 7 flower species:1. **Daisy** (*Bellis perennis*) β πΌ2. **Dandelion** (*Taraxacum officinale*) β π¦3. **Rose** (*Rosa*) β πΉ4. **Sunflower** (*Helianthus annuus*) β π»5. **Tulip** (*Tulipa*) β π·6. **Bellflower** (*Campanula*) β π7. **Lotus** (*Nelumbo nucifera*) β πͺ·---## π How to Run & Use the Model### 1. Interactive Web Application (Recommended)Launch the modern web UI with drag-and-drop file upload, live image preview, verified 1-click flower samples, real-time confidence scores, and animated probability spectrums:```bash# Start the FastAPI server (auto-detects port and opens browser)py app.py# Or on local network / Wi-Fi to test from your phone:py app.py --host 0.0.0.0 --port 8000```> **Windows Quick Launch**: You can also just double-click `run_app.bat`!### 2. Command-Line Interface (CLI)Classify any image directly from your terminal:```bashpy predict.py "test_images/download (3).jpg"# Output:# π Top Prediction: BELLFLOWER (100.0%)# Botanical Name: Campanula# Hardware: CUDA```### 3. Programmatic Python APIImport the model into your own Python code or Jupyter notebook:```pythonfrom model import predict_flower# Run inference on any image path or PIL imageresult = predict_flower("my_flower.jpg")print(f"Prediction: {result['top_flower']} ({result['confidence_pct']})")print("Top Probabilities:", result['probabilities'])```### 4. REST API EndpointSend image files via HTTP POST from any client (iOS, Android, React, cURL):```bashcurl -X POST "http://127.0.0.1:8000/api/predict" \-F "file=@test_images/download.jpg"```**Response Format**:```json{"success": true,"top_flower": "lotus","display_name": "Lotus","confidence": 0.605,"confidence_pct": "60.5%","ranked_list": [{"name": "lotus","display_name": "Lotus","probability": 0.605,"percentage": "60.5%","color": "#06b6d4","icon": "πͺ·"},{ "name": "tulip", "percentage": "36.4%", ... }],"flower_info": {"scientific_name": "Nelumbo nucifera","family": "Nelumbonaceae","icon": "πͺ·","season": "Summer"},"device": "cuda"}```### 5. Hugging Face Spaces (Free Global Cloud Deployment)Run the included Gradio interface or upload to Hugging Face:```bashpy gradio_app.py```To deploy to the world for free:1. Create a free account on [Hugging Face](https://huggingface.co/).2. Create a new Space (choose **Gradio** SDK).3. Upload `gradio_app.py`, `model.py`, and `flower_classifier.pth`.4. Anyone on the internet can now upload photos and test your model!---## ποΈ Neural Network Architecture```textInput Image (150 Γ 150 Γ 3 RGB) [Normalized / 255.0]ββββ [Conv Block 1]: Conv2d(3 -> 32, 3x3) + BatchNorm2d + ReLU + MaxPool2d(2x2) -> (32, 75, 75)βββ [Conv Block 2]: Conv2d(32 -> 64, 3x3) + BatchNorm2d + ReLU + MaxPool2d(2x2) -> (64, 37, 37)βββ [Conv Block 3]: Conv2d(64 -> 128, 3x3) + BatchNorm2d + ReLU + MaxPool2d(2x2)-> (128, 18, 18)ββββ Flatten -> 41,472 featuresβββ Linear(41,472 -> 128) + ReLU + Dropout(0.3)βββ Linear(128 -> 64) + ReLUβββ Linear(64 -> 32) + ReLUβββ Output Linear(32 -> 7) -> Softmax Probabilities (7 Classes)```- **Total Parameters**: 5,412,807- **Test Accuracy**: ~79% on 2,240 test samples- **Training Epochs**: 20 epochs with Adam (`lr=0.001`) & CrossEntropyLoss- **Hardware Acceleration**: CUDA RTX 5050 GPU (with automatic CPU fallback)---## π¬ Why Switch from an MLP to a CNN? (Engineering Post-Mortem)After training our two-layer NumPy Multilayer Perceptron (MLP) for 7,000 iterations and achieving ~90% training accuracy, empirical evaluation on unseen test images exposed a severe generalization bottleneck: real-world accuracy dropped to **40% (4/10)**.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198import ioimport osimport sysimport webbrowserfrom contextlib import asynccontextmanagerfrom pathlib import Pathfrom typing import List, Dict, Any
# Ensure UTF-8 output on Windows terminalsif hasattr(sys.stdout, "reconfigure"): sys.stdout.reconfigure(encoding="utf-8", errors="replace")if hasattr(sys.stderr, "reconfigure"): sys.stderr.reconfigure(encoding="utf-8", errors="replace")
from fastapi import FastAPI, File, UploadFile, HTTPExceptionfrom fastapi.middleware.cors import CORSMiddlewarefrom fastapi.responses import HTMLResponse, JSONResponse, FileResponsefrom fastapi.staticfiles import StaticFilesimport uvicorn
from model import ( FlowerClassifier, CATEGORIES, FLOWER_DETAILS, predict_flower, load_model, get_device,)
BASE_DIR = Path(__file__).resolve().parentSTATIC_DIR = BASE_DIR / "static"TEMPLATES_DIR = BASE_DIR / "templates"
@asynccontextmanagerasync def lifespan(app: FastAPI): """Pre-warm the PyTorch model on startup.""" try: model, device = load_model() print(f"[*] Model loaded successfully on {device}") except Exception as e: print(f"[!] Warning during model load: {e}") yield
app = FastAPI( title="ScratchNet Flower Classifier", description="Deep Learning CNN UI for 7-Class Flower Detection", version="1.0.0", lifespan=lifespan,)
# Enable CORS for local testing & embeddingapp.add_middleware( CORSMiddleware, allow_origins=["*"], allow_credentials=True, allow_methods=["*"], allow_headers=["*"],)
# Ensure required directories existSTATIC_DIR.mkdir(parents=True, exist_ok=True)TEMPLATES_DIR.mkdir(parents=True, exist_ok=True)
# Mount static filesapp.mount("/static", StaticFiles(directory=str(STATIC_DIR)), name="static")
@app.get("/", response_class=HTMLResponse)async def serve_index(): """Serves the main interactive web UI.""" index_file = TEMPLATES_DIR / "index.html" if not index_file.is_file(): raise HTTPException(status_code=404, detail="index.html not found") with open(index_file, "r", encoding="utf-8") as f: return HTMLResponse(content=f.read())
@app.post("/api/predict")async def predict_endpoint(file: UploadFile = File(...)): """ Accepts an uploaded image file, processes it through the trained CNN model, and returns the predicted flower class, confidence, ranked probabilities, and botanical metadata. """ if not file.content_type.startswith("image/"): raise HTTPException( status_code=400, detail=f"Uploaded file must be an image. Received: {file.content_type}", )
try: image_bytes = await file.read() if len(image_bytes) == 0: raise HTTPException(status_code=400, detail="Uploaded file is empty.")
result = predict_flower(image_bytes) return JSONResponse( content={ "success": True, "filename": file.filename, **result, } ) except Exception as e: return JSONResponse( status_code=500, content={"success": False, "error": str(e)}, )
@app.get("/api/samples")async def get_samples() -> Dict[str, Any]: """Returns the list of sample flowers available for quick 1-click testing.""" samples = [] samples_dir = STATIC_DIR / "samples" for cat in CATEGORIES: sample_img = samples_dir / f"{cat}.jpg" if sample_img.is_file(): info = FLOWER_DETAILS.get(cat, {}) samples.append({ "category": cat, "display_name": cat.capitalize(), "icon": info.get("icon", "πΈ"), "color": info.get("color", "#10b981"), "url": f"/static/samples/{cat}.jpg", }) return {"samples": samples}
@app.get("/api/health")async def health_check(): """Model status and hardware metadata.""" device = get_device() model, _ = load_model() total_params = sum(p.numel() for p in model.parameters()) trainable_params = sum(p.numel() for p in model.parameters() if p.requires_grad)
return { "status": "online", "device": str(device), "cuda_available": device.type == "cuda", "classes": CATEGORIES, "num_classes": len(CATEGORIES), "input_resolution": "150x150 RGB", "total_parameters": total_params, "trainable_parameters": trainable_params, "architecture": "3-Block CNN with BatchNorm and Dropout", }
def find_available_port(start_port: int = 8000, max_attempts: int = 20) -> int: """Finds an available port starting from start_port.""" import socket for port in range(start_port, start_port + max_attempts): with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: try: s.bind(("127.0.0.1", port)) return port except OSError: continue return start_port
def main(): import argparse parser = argparse.ArgumentParser(description="ScratchNet Flower Detection Web App") parser.add_argument("--host", type=str, default="127.0.0.1", help="Host interface (use 0.0.0.0 for LAN)") parser.add_argument("--port", type=int, default=None, help="Port to run server on") parser.add_argument("--no-browser", action="store_true", help="Do not automatically open the web browser") args = parser.parse_args()
host = args.host port = args.port if args.port is not None else find_available_port(8000) url = f"http://{host}:{port}"
print("\n" + "=" * 60) print(" πΈ ScratchNet Flower Detection Web App") print(f" π Server running at: {url}") print(" πΈ Upload or drag-and-drop images to detect the 7 flowers") print("=" * 60 + "\n")
if not args.no_browser: try: import threading def open_browser(): import time time.sleep(1.2) webbrowser.open(url) threading.Thread(target=open_browser, daemon=True).start() except Exception: pass
uvicorn.run("app:app", host=host, port=port, reload=False)
if __name__ == "__main__": main()123version https://git-lfs.github.com/spec/v1oid sha256:1a94d1e09525498235cfbc3e018d132ecb335dd7fd2fee24ad997b578c323a9bsize 21663786123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384import sysfrom pathlib import Path
# Ensure UTF-8 output on Windows terminalsif hasattr(sys.stdout, "reconfigure"): sys.stdout.reconfigure(encoding="utf-8", errors="replace")if hasattr(sys.stderr, "reconfigure"): sys.stderr.reconfigure(encoding="utf-8", errors="replace")
import gradio as grfrom PIL import Imagefrom model import predict_flower, CATEGORIES, FLOWER_DETAILS
def classify_flower(image): if image is None: return "Please upload an image.", {}, ""
res = predict_flower(image) top_name = res["display_name"] confidence = res["confidence_pct"] info = res["flower_info"] icon = info.get("icon", "πΈ") sci_name = info.get("scientific_name", "")
# Top prediction badge text title_text = f"## {icon} {top_name} ({confidence})\n*{sci_name}*"
# Dictionary of label -> probability for Gradio Label component prob_dict = {item["display_name"]: item["probability"] for item in res["ranked_list"]}
# Botanical details details_md = f"""### πΏ Botanical Profile:- **Family:** {info.get('family', 'N/A')}- **Blooms:** {info.get('season', 'N/A')}- **Description:** {info.get('description', '')}
*Inference Hardware:* `{res['device'].upper()}` """
return title_text, prob_dict, details_md
# Gather sample examplesexamples = []sample_dir = Path("static/samples")if sample_dir.is_dir(): for f in sorted(sample_dir.glob("*.jpg")): examples.append([str(f)])
with gr.Blocks(title="ScratchNet β 7-Class Flower Classifier") as demo: gr.Markdown(""" # πͺ· ScratchNet AI β 7-Class Flower Classifier Upload or capture a photo of a flower to classify between **Daisy, Dandelion, Rose, Sunflower, Tulip, Bellflower, and Lotus**. Powered by a custom 3-block 2D Convolutional Neural Network (PyTorch). """)
with gr.Row(): with gr.Column(): input_image = gr.Image(type="pil", label="Upload Flower Image") predict_btn = gr.Button("πΈ Classify Flower", variant="primary") if examples: gr.Examples(examples=examples, inputs=input_image, label="Verified Flower Samples")
with gr.Column(): output_title = gr.Markdown(label="Predicted Flower") output_labels = gr.Label(num_top_classes=7, label="Class Probabilities") output_details = gr.Markdown(label="Botanical Insights")
predict_btn.click( fn=classify_flower, inputs=input_image, outputs=[output_title, output_labels, output_details], ) input_image.change( fn=classify_flower, inputs=input_image, outputs=[output_title, output_labels, output_details], )
if __name__ == "__main__": print("Launching Gradio interface...") demo.launch(server_name="127.0.0.1", server_port=7860, share=False)123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275import osfrom pathlib import Pathfrom typing import Dict, List, Tuple, Union, Anyimport io
import numpy as npimport torchimport torch.nn as nnfrom PIL import Image
# 7 flower categories trained by the modelCATEGORIES: List[str] = [ "daisy", "dandelion", "rose", "sunflower", "tulip", "bellflower", "lotus",]
# Detailed botanical and aesthetic metadata for each flower classFLOWER_DETAILS: Dict[str, Dict[str, Any]] = { "daisy": { "scientific_name": "Bellis perennis", "family": "Asteraceae", "icon": "πΌ", "color": "#facc15", "tagline": "Radiant Innocence & Simplicity", "description": "Daisies feature classic white ray florets surrounding a bright yellow center disc. Known for closing their petals at night and reopening with the morning light.", "season": "Spring through Autumn", }, "dandelion": { "scientific_name": "Taraxacum officinale", "family": "Asteraceae", "icon": "π¦", "color": "#eab308", "tagline": "Golden Resilience & Wish-Maker", "description": "Known for its vivid golden yellow flower heads that mature into delicate spherical puffballs of downy seeds carried on the breeze.", "season": "Spring through Summer", }, "rose": { "scientific_name": "Rosa", "family": "Rosaceae", "icon": "πΉ", "color": "#f43f5e", "tagline": "Timeless Elegance & Romance", "description": "Celebrated worldwide for velvety spiral petals, sweet intoxicating fragrance, and thorny canes. Universal symbol of passion, love, and grace.", "season": "Late Spring through Autumn", }, "sunflower": { "scientific_name": "Helianthus annuus", "family": "Asteraceae", "icon": "π»", "color": "#f59e0b", "tagline": "Solar Majesty & Warmth", "description": "Famous for heliotropism (tracking the path of the sun). Features towering stalks topped by magnificent large heads with vibrant yellow petals.", "season": "Mid Summer through Early Autumn", }, "tulip": { "scientific_name": "Tulipa", "family": "Liliaceae", "icon": "π·", "color": "#ec4899", "tagline": "Springtime Vibrance & Renewal", "description": "Elegant cup-shaped blooms in symmetrical proportions. Highly prized throughout history, notably sparking the famous Dutch Golden Age tulip boom.", "season": "Early to Mid Spring", }, "bellflower": { "scientific_name": "Campanula", "family": "Campanulaceae", "icon": "π", "color": "#8b5cf6", "tagline": "Whimsical Violet Grace", "description": "Distinguished by delightful bell-like five-lobed petals blooming in rich shades of purple, blue, violet, and occasionally white.", "season": "Late Spring to Mid Summer", }, "lotus": { "scientific_name": "Nelumbo nucifera", "family": "Nelumbonaceae", "icon": "πͺ·", "color": "#06b6d4", "tagline": "Sacred Purity & Enlightenment", "description": "An aquatic perennial rooted in muddy riverbeds that rises pristine above water. Revered in ancient cultures as a sacred symbol of spiritual rebirth and resilience.", "season": "Summer", },}
TARGET_SIZE: Tuple[int, int] = (150, 150)
class FlowerClassifier(nn.Module): """ Convolutional Neural Network (CNN) architecture trained on the 7-flower dataset. Structure: - 3 Convolutional Blocks: (Conv2d -> BatchNorm2d -> ReLU -> MaxPool2d) - Flatten: 128 channels * 18 * 18 spatial resolution = 41,472 features - Fully Connected Dense Layers: 41,472 -> 128 -> 64 -> 32 -> 7 logits """
def __init__(self, num_classes: int = 7): super().__init__()
# Conv Block 1: 3 -> 32 channels (150x150 -> 75x75) self.cnn_layer = nn.Sequential( nn.Conv2d(in_channels=3, out_channels=32, kernel_size=3, padding=1, stride=1, bias=True), nn.BatchNorm2d(32), nn.ReLU(), nn.MaxPool2d(kernel_size=2, stride=2), )
# Conv Block 2: 32 -> 64 channels (75x75 -> 37x37) self.cnn_layer_2 = nn.Sequential( nn.Conv2d(in_channels=32, out_channels=64, kernel_size=3, padding=1, stride=1, bias=True), nn.BatchNorm2d(64), nn.ReLU(), nn.MaxPool2d(kernel_size=2, stride=2), )
# Conv Block 3: 64 -> 128 channels (37x37 -> 18x18) self.cnn_layer_3 = nn.Sequential( nn.Conv2d(in_channels=64, out_channels=128, kernel_size=3, padding=1, stride=1, bias=True), nn.BatchNorm2d(128), nn.ReLU(), nn.MaxPool2d(kernel_size=2, stride=2), )
# Dense Classifier Head self.flatten = nn.Flatten() self.layer_1 = nn.Sequential( nn.Linear(in_features=128 * 18 * 18, out_features=128, bias=True), nn.ReLU(), nn.Dropout(0.3), ) self.layer_2 = nn.Sequential( nn.Linear(in_features=128, out_features=64, bias=True), nn.ReLU(), ) self.layer_3 = nn.Sequential( nn.Linear(in_features=64, out_features=32, bias=True), nn.ReLU(), ) self.out = nn.Linear(in_features=32, out_features=num_classes)
def forward(self, x: torch.Tensor) -> torch.Tensor: x = self.cnn_layer(x) x = self.cnn_layer_2(x) x = self.cnn_layer_3(x) x = self.flatten(x) x = self.layer_1(x) x = self.layer_2(x) x = self.layer_3(x) x = self.out(x) return x
_cached_model: Union[FlowerClassifier, None] = None_cached_device: Union[torch.device, None] = None
def get_device() -> torch.device: global _cached_device if _cached_device is None: _cached_device = torch.device("cuda" if torch.cuda.is_available() else "cpu") return _cached_device
def load_model(weights_path: Union[str, Path] = "flower_classifier.pth") -> Tuple[FlowerClassifier, torch.device]: """ Loads the trained PyTorch model with cached singleton pattern. """ global _cached_model device = get_device()
if _cached_model is not None: return _cached_model, device
path = Path(weights_path) if not path.is_file(): # Check current directory or parent alt_path = Path(__file__).resolve().parent / weights_path if alt_path.is_file(): path = alt_path else: raise FileNotFoundError(f"Model checkpoint not found at: {weights_path}")
model = FlowerClassifier(num_classes=len(CATEGORIES)).to(device) state_dict = torch.load(str(path), map_location=device) model.load_state_dict(state_dict) model.eval()
_cached_model = model return _cached_model, device
def preprocess_image(image_input: Union[Image.Image, bytes, bytearray, str, Path]) -> torch.Tensor: """ Preprocess an image exactly as done during model training: 1. Open / convert to RGB format. 2. Resize to (150, 150). 3. Scale pixel values from [0, 255] to [0.0, 1.0]. 4. Convert to float32 tensor with shape (1, 3, 150, 150). """ if isinstance(image_input, (bytes, bytearray)): image = Image.open(io.BytesIO(image_input)).convert("RGB") elif isinstance(image_input, (str, Path)): image = Image.open(str(image_input)).convert("RGB") elif isinstance(image_input, Image.Image): image = image_input.convert("RGB") else: raise ValueError(f"Unsupported image input type: {type(image_input)}")
# Resize to model target input size image = image.resize(TARGET_SIZE, Image.Resampling.BILINEAR) # Array to (H, W, C) float32 normalized arr = np.array(image, dtype=np.float32) / 255.0 # Permute to (C, H, W) and add batch dim -> (1, 3, 150, 150) tensor = torch.from_numpy(arr).permute(2, 0, 1).unsqueeze(0) return tensor
def predict_flower(image_input: Union[Image.Image, bytes, bytearray, str, Path]) -> Dict[str, Any]: """ Runs model inference on the provided flower image. Returns: - 'top_flower': Predicted class name (e.g. 'sunflower') - 'confidence': Prediction probability (0.0 to 1.0) - 'confidence_pct': Formatted percentage string (e.g. '98.5%') - 'probabilities': Dictionary of {category: probability} sorted descending - 'ranked_list': List of {name, probability, percentage, color, icon} - 'flower_info': Botanical metadata dictionary - 'device': Inference hardware device ('cuda' or 'cpu') """ model, device = load_model() tensor = preprocess_image(image_input).to(device)
with torch.inference_mode(): logits = model(tensor) probs = torch.softmax(logits, dim=1)[0].cpu().numpy()
sorted_indices = np.argsort(probs)[::-1] top_idx = int(sorted_indices[0]) top_category = CATEGORIES[top_idx] top_confidence = float(probs[top_idx])
ranked_list = [] probabilities_dict = {} for idx in sorted_indices: cat = CATEGORIES[idx] p = float(probs[idx]) probabilities_dict[cat] = p detail = FLOWER_DETAILS.get(cat, {}) ranked_list.append({ "name": cat, "display_name": cat.capitalize(), "probability": round(p, 4), "percentage": f"{p * 100:.1f}%", "percent_value": round(p * 100, 1), "color": detail.get("color", "#10b981"), "icon": detail.get("icon", "πΈ"), })
return { "top_flower": top_category, "display_name": top_category.capitalize(), "confidence": round(top_confidence, 4), "confidence_pct": f"{top_confidence * 100:.1f}%", "probabilities": probabilities_dict, "ranked_list": ranked_list, "flower_info": FLOWER_DETAILS.get(top_category, {}), "device": str(device), }123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657import argparseimport sysfrom pathlib import Path
# Ensure UTF-8 output on Windows terminalsif hasattr(sys.stdout, "reconfigure"): sys.stdout.reconfigure(encoding="utf-8", errors="replace")if hasattr(sys.stderr, "reconfigure"): sys.stderr.reconfigure(encoding="utf-8", errors="replace")
from model import predict_flower, CATEGORIES
def main(): parser = argparse.ArgumentParser( description="ScratchNet Flower Classifier β CLI Image Predictor", formatter_class=argparse.RawDescriptionHelpFormatter, epilog="""Examples: py predict.py test_images/download.jpg py predict.py path/to/rose.png """, ) parser.add_argument("image_path", type=str, help="Path to the flower image file.") args = parser.parse_args()
img_path = Path(args.image_path) if not img_path.is_file(): print(f"Error: File not found: {args.image_path}", file=sys.stderr) sys.exit(1)
print(f"\nAnalyzing: {img_path.name} ...") try: result = predict_flower(img_path) except Exception as e: print(f"Error during inference: {e}", file=sys.stderr) sys.exit(1)
winner = result["top_flower"] conf = result["confidence_pct"] device = result["device"] info = result["flower_info"]
print("=" * 50) print(f" {info.get('icon', 'πΈ')} Top Prediction: {winner.upper()} ({conf})") print(f" Botanical Name: {info.get('scientific_name', 'N/A')}") print(f" Hardware: {device.upper()}") print("-" * 50) print(" Full Probability Spectrum:") for item in result["ranked_list"]: bar = "β" * int(item["percent_value"] / 5) print(f" {item['icon']} {item['display_name']:12s} {item['percentage']:>6s} | {bar}") print("=" * 50 + "\n")
if __name__ == "__main__": main()12345torchtorchvisionpillownumpygradio1234567891011121314@echo offtitle ScratchNet Flower Classifierecho ========================================================echo ScratchNet 7-Class Flower Classifierecho Starting web application...echo ========================================================echo.py app.pyif errorlevel 1 ( echo. echo [!] Encountered an issue running with 'py'. Trying 'python'... python app.py)pause123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316/** * ScratchNet β 7-Class Flower Classifier * Frontend Controller & Interactive Neural Network Client */
document.addEventListener('DOMContentLoaded', () => { // DOM Elements const dropzone = document.getElementById('dropzone'); const dropzoneEmpty = document.getElementById('dropzoneEmpty'); const dropzonePreview = document.getElementById('dropzonePreview'); const fileInput = document.getElementById('fileInput'); const browseFilesBtn = document.getElementById('browseFilesBtn'); const previewImage = document.getElementById('previewImage'); const previewFilename = document.getElementById('previewFilename'); const previewFilesize = document.getElementById('previewFilesize'); const clearImageBtn = document.getElementById('clearImageBtn'); const analyzeBtn = document.getElementById('analyzeBtn'); const btnSpinner = document.getElementById('btnSpinner'); const analyzeBtnText = document.getElementById('analyzeBtnText');
const resultPlaceholder = document.getElementById('resultPlaceholder'); const resultContent = document.getElementById('resultContent'); const winnerName = document.getElementById('winnerName'); const winnerScientific = document.getElementById('winnerScientific'); const winnerIcon = document.getElementById('winnerIcon'); const winnerConfidence = document.getElementById('winnerConfidence'); const winnerDescription = document.getElementById('winnerDescription'); const winnerFamily = document.getElementById('winnerFamily'); const winnerSeason = document.getElementById('winnerSeason'); const probabilitiesList = document.getElementById('probabilitiesList'); const jsonCodeOutput = document.getElementById('jsonCodeOutput');
const hardwareStatusBadge = document.getElementById('hardwareStatusBadge'); const hardwareStatusText = document.getElementById('hardwareStatusText'); const inferenceDeviceBadge = document.getElementById('inferenceDeviceBadge'); const samplesContainer = document.getElementById('samplesContainer');
// State let currentFile = null;
// 1. Initial Health Check fetch('/api/health') .then(res => res.json()) .then(data => { if (data.cuda_available) { hardwareStatusText.textContent = `β‘ CUDA Acceleration (${data.device.toUpperCase()})`; hardwareStatusBadge.style.borderColor = 'rgba(16, 185, 129, 0.4)'; } else { hardwareStatusText.textContent = `π» CPU Active (${data.device.toUpperCase()})`; hardwareStatusBadge.style.borderColor = 'rgba(245, 158, 11, 0.4)'; } inferenceDeviceBadge.textContent = `${data.num_classes} Classes β’ ${data.device.toUpperCase()}`; }) .catch(() => { hardwareStatusText.textContent = 'β Backend Connected'; });
// 2. Fetch & Render Quick Test Samples fetch('/api/samples') .then(res => res.json()) .then(data => { if (!data.samples || data.samples.length === 0) { samplesContainer.innerHTML = '<span class="samples-hint">No pre-loaded samples found.</span>'; return; }
samplesContainer.innerHTML = ''; data.samples.forEach(sample => { const card = document.createElement('div'); card.className = 'sample-card'; card.setAttribute('data-category', sample.category); card.innerHTML = ` <div class="sample-thumb-wrapper"> <img src="${sample.url}" alt="${sample.display_name}" class="sample-thumb" loading="lazy"> </div> <div class="sample-name-badge"> <span>${sample.icon}</span> <span>${sample.display_name}</span> </div> `;
card.addEventListener('click', () => loadSampleImage(sample.url, sample.category)); samplesContainer.appendChild(card); }); }) .catch(err => { samplesContainer.innerHTML = '<span class="samples-hint">Could not load samples.</span>'; console.error(err); });
// 3. File Input Trigger browseFilesBtn.addEventListener('click', (e) => { e.stopPropagation(); fileInput.click(); });
dropzone.addEventListener('click', () => { if (!currentFile) { fileInput.click(); } });
fileInput.addEventListener('change', (e) => { if (e.target.files && e.target.files[0]) { handleSelectedFile(e.target.files[0]); } });
// 4. Drag & Drop Event Handlers ['dragenter', 'dragover'].forEach(eventName => { dropzone.addEventListener(eventName, (e) => { e.preventDefault(); e.stopPropagation(); dropzone.classList.add('dragover'); }); });
['dragleave', 'drop'].forEach(eventName => { dropzone.addEventListener(eventName, (e) => { e.preventDefault(); e.stopPropagation(); dropzone.classList.remove('dragover'); }); });
dropzone.addEventListener('drop', (e) => { const dt = e.dataTransfer; if (dt.files && dt.files[0]) { handleSelectedFile(dt.files[0]); } });
// 5. Global Clipboard Paste Handler (Ctrl+V) window.addEventListener('paste', (e) => { if (e.clipboardData && e.clipboardData.items) { const items = e.clipboardData.items; for (let i = 0; i < items.length; i++) { if (items[i].type.indexOf('image') !== -1) { const blob = items[i].getAsFile(); handleSelectedFile(blob, 'pasted_image.png'); break; } } } });
// 6. Clear Image Button clearImageBtn.addEventListener('click', (e) => { e.stopPropagation(); resetDropzone(); });
function resetDropzone() { currentFile = null; fileInput.value = ''; dropzoneEmpty.style.display = 'flex'; dropzonePreview.style.display = 'none'; previewImage.src = ''; analyzeBtn.disabled = true; // Remove active state on sample cards document.querySelectorAll('.sample-card').forEach(c => c.classList.remove('active')); }
function handleSelectedFile(file, overrideName = null) { if (!file.type.startsWith('image/')) { alert('Please select a valid image file (JPG, PNG, WEBP, BMP).'); return; }
currentFile = file; const name = overrideName || file.name || 'image.jpg'; const sizeFormatted = (file.size / 1024).toFixed(1) + ' KB';
previewFilename.textContent = name; previewFilesize.textContent = sizeFormatted;
const reader = new FileReader(); reader.onload = (e) => { previewImage.src = e.target.result; dropzoneEmpty.style.display = 'none'; dropzonePreview.style.display = 'flex'; analyzeBtn.disabled = false; }; reader.readAsDataURL(file); }
// 7. Load & Auto-Analyze a Sample Flower function loadSampleImage(url, category) { // Highlight active sample card document.querySelectorAll('.sample-card').forEach(c => { if (c.getAttribute('data-category') === category) { c.classList.add('active'); } else { c.classList.remove('active'); } });
fetch(url) .then(res => res.blob()) .then(blob => { const sampleFile = new File([blob], `${category}.jpg`, { type: 'image/jpeg' }); handleSelectedFile(sampleFile, `${category}_sample.jpg`); // Auto trigger detection for quick feedback runInference(sampleFile); }) .catch(err => { console.error('Failed to load sample image:', err); }); }
// 8. Analyze Button Trigger analyzeBtn.addEventListener('click', () => { if (currentFile) { runInference(currentFile); } });
// 9. Inference Execution Function function runInference(file) { // UI Loading State analyzeBtn.disabled = true; btnSpinner.style.display = 'inline-block'; analyzeBtnText.textContent = 'Classifying Flower...';
const formData = new FormData(); formData.append('file', file);
fetch('/api/predict', { method: 'POST', body: formData, }) .then(res => { if (!res.ok) { throw new Error(`Inference error: HTTP ${res.status}`); } return res.json(); }) .then(data => { if (data.success) { renderPredictionResults(data); } else { alert('Prediction failed: ' + (data.error || 'Unknown error')); } }) .catch(err => { console.error('Error during prediction:', err); alert('Could not complete prediction. Please verify the server is running.'); }) .finally(() => { analyzeBtn.disabled = false; btnSpinner.style.display = 'none'; analyzeBtnText.textContent = 'Analyze Flower'; }); }
// 10. Render Prediction Results & Progress Bars function renderPredictionResults(data) { resultPlaceholder.style.display = 'none'; resultContent.style.display = 'flex';
// Winner Card const topInfo = data.flower_info || {}; winnerName.textContent = data.display_name; winnerScientific.textContent = topInfo.scientific_name || ''; winnerIcon.textContent = topInfo.icon || 'πΈ'; winnerConfidence.textContent = data.confidence_pct; winnerDescription.textContent = topInfo.description || ''; winnerFamily.textContent = topInfo.family || 'Botanical'; winnerSeason.textContent = topInfo.season || 'Annual';
if (topInfo.color) { winnerConfidence.style.color = topInfo.color; winnerName.style.color = topInfo.color; }
// Probabilities List probabilitiesList.innerHTML = ''; if (data.ranked_list && data.ranked_list.length > 0) { data.ranked_list.forEach((item, index) => { const probItem = document.createElement('div'); probItem.className = 'prob-item';
const isWinner = index === 0; probItem.innerHTML = ` <div class="prob-info-row"> <div class="prob-name-group" style="${isWinner ? 'color: ' + item.color + ';' : ''}"> <span>${item.icon}</span> <span>${item.display_name}</span> </div> <span class="prob-pct-val" style="${isWinner ? 'color: ' + item.color + ';' : ''}"> ${item.percentage} </span> </div> <div class="prob-bar-track"> <div class="prob-bar-fill" id="probBar_${item.name}" style="background: ${item.color}; width: 0%;"></div> </div> `; probabilitiesList.appendChild(probItem);
// Animate progress bar fill width after insertion requestAnimationFrame(() => { setTimeout(() => { const bar = document.getElementById(`probBar_${item.name}`); if (bar) { bar.style.width = `${item.percent_value}%`; } }, 50 * index); }); }); }
// Raw JSON output jsonCodeOutput.textContent = JSON.stringify(data, null, 2); }});1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102:root { --bg-dark: #0a0f0d; --bg-surface: rgba(18, 26, 22, 0.75); --bg-card: rgba(24, 35, 30, 0.65); --bg-card-hover: rgba(30, 45, 38, 0.85); --border-subtle: rgba(255, 255, 255, 0.08); --border-highlight: rgba(16, 185, 129, 0.35);
--primary: #10b981; --primary-glow: rgba(16, 185, 129, 0.4); --primary-gradient: linear-gradient(135deg, #10b981 0%, #059669 100%); --accent-floral: #ec4899; --accent-sun: #f59e0b;
--text-primary: #f8fafc; --text-secondary: #94a3b8; --text-muted: #64748b;
--radius-sm: 8px; --radius-md: 14px; --radius-lg: 20px; --radius-full: 9999px;
--shadow-card: 0 10px 30px -10px rgba(0, 0, 0, 0.6); --shadow-glow: 0 0 25px -5px var(--primary-glow);
--transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0;}
body { font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif; background-color: var(--bg-dark); color: var(--text-primary); min-height: 100vh; overflow-x: hidden; line-height: 1.6;}
/* Ambient Glowing Background Orbs */.background-ambient { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; z-index: -1; overflow: hidden; pointer-events: none;}
.glow-orb { position: absolute; border-radius: 50%; filter: blur(120px); opacity: 0.25; animation: floatOrb 18s ease-in-out infinite alternate;}
.orb-1 { top: -10%; left: 15%; width: 500px; height: 500px; background: radial-gradient(circle, #059669 0%, transparent 70%);}
.orb-2 { bottom: -15%; right: 10%; width: 600px; height: 600px; background: radial-gradient(circle, #ec4899 0%, transparent 70%); animation-delay: -6s;}
.orb-3 { top: 40%; right: 25%; width: 400px; height: 400px; background: radial-gradient(circle, #f59e0b 0%, transparent 70%); animation-delay: -12s;}
@keyframes floatOrb { 0% { transform: translate(0, 0) scale(1); } 50% { transform: translate(30px, 40px) scale(1.08); } 100% { transform: translate(-30px, 20px) scale(0.95); }}
/* Header & Navbar */.navbar { position: sticky; top: 0; z-index: 100; background: rgba(10, 15, 13, 0.82); backdrop-filter: blur(16px); border-bottom: 1px solid var(--border-subtle);}
.nav-container { max-width: 1280px; margin: 0 auto; padding: 1rem 1.5rem; display: flex; align-items: center; justify-content: space-between;}
.brand { display: flex; align-items: center; gap: 0.75rem; text-decoration: none;}
.brand-icon { font-size: 2rem; filter: drop-shadow(0 0 10px rgba(16, 185, 129, 0.4));}
.brand-name { font-family: 'Outfit', sans-serif; font-size: 1.35rem; font-weight: 700; letter-spacing: -0.02em; color: var(--text-primary);}
.brand-ai { background: var(--primary-gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent;}
.brand-tag { display: block; font-size: 0.75rem; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.06em;}
.nav-actions { display: flex; align-items: center; gap: 1rem;}
.status-badge { display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.4rem 0.85rem; background: rgba(16, 185, 129, 0.1); border: 1px solid rgba(16, 185, 129, 0.25); border-radius: var(--radius-full); font-size: 0.8rem; font-weight: 600; color: var(--primary);}
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); box-shadow: 0 0 10px var(--primary); animation: pulseDot 2s infinite;}
@keyframes pulseDot { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.4; transform: scale(0.85); }}
.btn-ghost { display: inline-flex; align-items: center; padding: 0.45rem 1rem; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--border-subtle); border-radius: var(--radius-full); color: var(--text-secondary); text-decoration: none; font-size: 0.85rem; font-weight: 500; transition: var(--transition);}
.btn-ghost:hover { color: var(--text-primary); background: rgba(255, 255, 255, 0.1); border-color: rgba(255, 255, 255, 0.2);}
/* Main Container */.main-content { max-width: 1280px; margin: 0 auto; padding: 2.5rem 1.5rem 5rem; display: flex; flex-direction: column; gap: 3rem;}
/* Hero Section */.hero-section { text-align: center; max-width: 840px; margin: 0 auto;}
.hero-badge { display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.35rem 1rem; background: rgba(255, 255, 255, 0.04); border: 1px solid var(--border-subtle); border-radius: var(--radius-full); font-size: 0.82rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 1.25rem;}
.badge-sparkle { font-size: 0.95rem;}
.hero-title { font-family: 'Outfit', sans-serif; font-size: 2.75rem; font-weight: 800; line-height: 1.18; letter-spacing: -0.03em; margin-bottom: 1rem;}
.gradient-text { background: linear-gradient(135deg, #34d399 0%, #10b981 50%, #06b6d4 100%); -webkit-background-clip: text; -webkit-text-fill-color: transparent;}
.hero-subtitle { font-size: 1.1rem; color: var(--text-secondary); font-weight: 400; max-width: 720px; margin: 0 auto;}
.hero-subtitle strong { color: var(--text-primary);}
/* Quick Samples Carousel / Grid */.samples-section { background: var(--bg-surface); backdrop-filter: blur(12px); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); padding: 1.25rem 1.5rem; box-shadow: var(--shadow-card);}
.samples-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; flex-wrap: wrap; gap: 0.5rem;}
.samples-label { font-size: 0.88rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-primary);}
.samples-hint { font-size: 0.82rem; color: var(--text-muted);}
.samples-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 0.85rem;}
.sample-card { background: rgba(255, 255, 255, 0.03); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); padding: 0.65rem; display: flex; flex-direction: column; align-items: center; gap: 0.5rem; cursor: pointer; transition: var(--transition); user-select: none;}
.sample-card:hover { transform: translateY(-4px); background: rgba(255, 255, 255, 0.08); border-color: var(--border-highlight); box-shadow: 0 8px 20px -6px rgba(16, 185, 129, 0.3);}
.sample-card.active { border-color: var(--primary); background: rgba(16, 185, 129, 0.15); box-shadow: 0 0 15px rgba(16, 185, 129, 0.4);}
.sample-thumb-wrapper { width: 100%; aspect-ratio: 1; border-radius: var(--radius-sm); overflow: hidden; position: relative; background: #111;}
.sample-thumb { width: 100%; height: 100%; object-fit: cover; transition: transform 0.35s ease;}
.sample-card:hover .sample-thumb { transform: scale(1.08);}
.sample-name-badge { font-size: 0.82rem; font-weight: 600; color: var(--text-primary); display: flex; align-items: center; gap: 0.35rem;}
.sample-skeleton { padding: 1rem; text-align: center; color: var(--text-muted); font-size: 0.88rem; grid-column: 1 / -1;}
/* Interactive Workbench Grid (Upload & Results) */.workbench-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem;}
@media (max-width: 960px) { .workbench-grid { grid-template-columns: 1fr; }}
.panel-card { background: var(--bg-surface); backdrop-filter: blur(16px); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); padding: 1.75rem; box-shadow: var(--shadow-card); display: flex; flex-direction: column; gap: 1.5rem;}
.panel-header { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border-subtle); padding-bottom: 1rem;}
.panel-title { font-family: 'Outfit', sans-serif; font-size: 1.25rem; font-weight: 700; display: flex; align-items: center; gap: 0.5rem;}
.panel-icon { font-size: 1.35rem;}
.panel-badge { font-size: 0.75rem; font-weight: 600; color: var(--text-muted); background: rgba(255, 255, 255, 0.04); padding: 0.25rem 0.65rem; border-radius: var(--radius-full);}
/* Dropzone Area */.dropzone { border: 2px dashed rgba(255, 255, 255, 0.15); border-radius: var(--radius-md); background: rgba(255, 255, 255, 0.015); min-height: 280px; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: var(--transition); position: relative; overflow: hidden;}
.dropzone:hover, .dropzone.dragover { border-color: var(--primary); background: rgba(16, 185, 129, 0.05); box-shadow: inset 0 0 20px rgba(16, 185, 129, 0.1);}
.dropzone-empty { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 2.5rem 1.5rem; gap: 0.75rem;}
.dropzone-icon-ring { width: 68px; height: 68px; border-radius: 50%; background: rgba(16, 185, 129, 0.1); border: 1px solid rgba(16, 185, 129, 0.25); display: flex; align-items: center; justify-content: center; margin-bottom: 0.5rem; color: var(--primary); transition: var(--transition);}
.dropzone:hover .dropzone-icon-ring { transform: scale(1.08); background: rgba(16, 185, 129, 0.2);}
.upload-svg { width: 32px; height: 32px;}
.dropzone-title { font-family: 'Outfit', sans-serif; font-size: 1.15rem; font-weight: 600;}
.dropzone-desc { font-size: 0.85rem; color: var(--text-muted);}
.dropzone-actions { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; margin-top: 0.5rem;}
.btn-primary { background: var(--primary-gradient); color: white; border: none; border-radius: var(--radius-full); padding: 0.65rem 1.5rem; font-size: 0.92rem; font-weight: 600; cursor: pointer; transition: var(--transition); box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(16, 185, 129, 0.45);}
.paste-hint { font-size: 0.75rem; color: var(--text-muted);}
.paste-hint kbd { background: rgba(255, 255, 255, 0.1); padding: 0.15rem 0.35rem; border-radius: 4px; font-family: monospace; font-size: 0.72rem;}
/* Image Preview */.dropzone-preview { width: 100%; padding: 1.25rem; display: flex; flex-direction: column; align-items: center; gap: 1rem;}
.preview-wrapper { position: relative; max-width: 260px; width: 100%; aspect-ratio: 1; border-radius: var(--radius-md); overflow: hidden; box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5); border: 2px solid var(--border-subtle);}
.preview-wrapper img { width: 100%; height: 100%; object-fit: cover; display: block;}
.preview-overlay { position: absolute; top: 8px; right: 8px;}
.btn-icon { width: 32px; height: 32px; border-radius: 50%; background: rgba(0, 0, 0, 0.7); color: white; border: 1px solid rgba(255, 255, 255, 0.2); display: flex; align-items: center; justify-content: center; cursor: pointer; transition: var(--transition);}
.btn-icon:hover { background: #ef4444; transform: scale(1.1);}
.preview-meta { display: flex; gap: 1rem; font-size: 0.8rem; color: var(--text-muted);}
/* Analyze Action Button */.upload-controls { display: flex; flex-direction: column; gap: 0.75rem;}
.btn-submit { background: var(--primary-gradient); color: white; border: none; border-radius: var(--radius-md); padding: 0.95rem 1.5rem; font-size: 1.05rem; font-weight: 700; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 0.65rem; transition: var(--transition); box-shadow: 0 8px 25px rgba(16, 185, 129, 0.35);}
.btn-submit:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 12px 30px rgba(16, 185, 129, 0.5);}
.btn-submit:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none;}
.btn-spinner { width: 18px; height: 18px; border: 2.5px solid rgba(255, 255, 255, 0.3); border-top-color: white; border-radius: 50%; animation: spin 0.8s linear infinite;}
@keyframes spin { to { transform: rotate(360deg); }}
/* Result Panel */.result-placeholder { min-height: 320px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 3rem 1.5rem; gap: 0.75rem;}
.placeholder-art { width: 76px; height: 76px; border-radius: 50%; background: rgba(255, 255, 255, 0.04); display: flex; align-items: center; justify-content: center; font-size: 2.5rem; margin-bottom: 0.5rem; animation: gentleFloat 4s ease-in-out infinite alternate;}
@keyframes gentleFloat { 0% { transform: translateY(0); } 100% { transform: translateY(-8px); }}
.placeholder-title { font-family: 'Outfit', sans-serif; font-size: 1.25rem; font-weight: 600;}
.placeholder-desc { font-size: 0.88rem; color: var(--text-muted); max-width: 320px;}
/* Live Results Content */.result-content { display: flex; flex-direction: column; gap: 1.5rem; animation: fadeIn 0.4s ease;}
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); }}
/* Primary Winner Card */.winner-card { background: linear-gradient(145deg, rgba(30, 45, 38, 0.9) 0%, rgba(18, 26, 22, 0.9) 100%); border: 1px solid var(--border-highlight); border-radius: var(--radius-md); padding: 1.5rem; display: flex; flex-direction: column; gap: 1.25rem; box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5); position: relative; overflow: hidden;}
.winner-card::before { content: ''; position: absolute; top: 0; left: 0; width: 4px; height: 100%; background: var(--primary);}
.winner-header { display: flex; align-items: center; gap: 1rem;}
.winner-icon-circle { width: 64px; height: 64px; border-radius: var(--radius-md); background: rgba(16, 185, 129, 0.15); border: 1px solid rgba(16, 185, 129, 0.3); display: flex; align-items: center; justify-content: center; font-size: 2.25rem; flex-shrink: 0;}
.winner-titles { flex-grow: 1;}
.winner-tag { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--primary);}
.winner-name { font-family: 'Outfit', sans-serif; font-size: 1.85rem; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1;}
.winner-scientific { font-size: 0.88rem; color: var(--text-muted); font-style: italic;}
.winner-gauge { display: flex; flex-direction: column; align-items: flex-end; background: rgba(0, 0, 0, 0.35); padding: 0.5rem 0.85rem; border-radius: var(--radius-sm); border: 1px solid var(--border-subtle);}
.gauge-value { font-family: 'Outfit', sans-serif; font-size: 1.45rem; font-weight: 800; color: #34d399;}
.gauge-label { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; font-weight: 600;}
.winner-description { font-size: 0.88rem; color: var(--text-secondary); line-height: 1.5;}
.winner-attributes { display: flex; gap: 0.75rem; flex-wrap: wrap;}
.attr-pill { background: rgba(255, 255, 255, 0.04); border: 1px solid var(--border-subtle); padding: 0.3rem 0.75rem; border-radius: var(--radius-full); font-size: 0.78rem; display: inline-flex; gap: 0.35rem;}
.attr-key { color: var(--text-muted);}
.attr-val { color: var(--text-primary); font-weight: 600;}
/* Probabilities Spectrum Breakdown */.probabilities-section { display: flex; flex-direction: column; gap: 0.75rem;}
.prob-section-title { font-size: 0.85rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-secondary);}
.prob-list { display: flex; flex-direction: column; gap: 0.55rem;}
.prob-item { display: flex; flex-direction: column; gap: 0.25rem;}
.prob-info-row { display: flex; justify-content: space-between; font-size: 0.84rem;}
.prob-name-group { display: flex; align-items: center; gap: 0.45rem; font-weight: 600;}
.prob-pct-val { font-weight: 700; font-family: monospace;}
.prob-bar-track { height: 8px; width: 100%; background: rgba(255, 255, 255, 0.06); border-radius: var(--radius-full); overflow: hidden;}
.prob-bar-fill { height: 100%; border-radius: var(--radius-full); width: 0%; transition: width 0.7s cubic-bezier(0.16, 1, 0.3, 1);}
/* Developer JSON View */.json-details { background: rgba(0, 0, 0, 0.3); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); padding: 0.75rem 1rem; font-size: 0.82rem;}
.json-summary { cursor: pointer; font-weight: 600; color: var(--text-muted); transition: var(--transition);}
.json-summary:hover { color: var(--primary);}
.json-pre { margin-top: 0.75rem; padding: 0.75rem; background: rgba(0, 0, 0, 0.5); border-radius: var(--radius-sm); overflow-x: auto; font-family: monospace; font-size: 0.78rem; color: #a7f3d0;}
/* Guide Section ("How Will Users Use My Model?") */.guide-section { display: flex; flex-direction: column; gap: 2rem; padding-top: 1rem; border-top: 1px solid var(--border-subtle);}
.section-title-wrapper { text-align: center; max-width: 760px; margin: 0 auto;}
.section-badge { display: inline-block; font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--primary); margin-bottom: 0.5rem;}
.section-heading { font-family: 'Outfit', sans-serif; font-size: 2.2rem; font-weight: 800; letter-spacing: -0.02em; margin-bottom: 0.75rem;}
.section-subheading { color: var(--text-secondary); font-size: 1rem;}
.guide-cards-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.5rem;}
.guide-card { background: var(--bg-surface); backdrop-filter: blur(12px); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); padding: 1.75rem; display: flex; flex-direction: column; gap: 1rem; box-shadow: var(--shadow-card); transition: var(--transition);}
.guide-card:hover { transform: translateY(-4px); border-color: rgba(16, 185, 129, 0.3); box-shadow: 0 12px 30px -10px rgba(0, 0, 0, 0.7);}
.guide-icon-bubble { width: 48px; height: 48px; border-radius: 50%; background: rgba(255, 255, 255, 0.05); display: flex; align-items: center; justify-content: center; font-size: 1.5rem;}
.guide-card-title { font-family: 'Outfit', sans-serif; font-size: 1.18rem; font-weight: 700;}
.guide-card-desc { font-size: 0.88rem; color: var(--text-secondary); line-height: 1.5; flex-grow: 1;}
.code-snippet { background: rgba(0, 0, 0, 0.55); border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); padding: 0.85rem; overflow-x: auto;}
.code-snippet code { font-family: 'Fira Code', monospace; font-size: 0.78rem; color: #e2e8f0; white-space: pre-wrap;}
/* Technical Architecture Section */.tech-section { background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); padding: 2.25rem;}
.tech-card { display: grid; grid-template-columns: 1.4fr 1fr; gap: 2.5rem; align-items: center;}
@media (max-width: 860px) { .tech-card { grid-template-columns: 1fr; }}
.tech-title { font-family: 'Outfit', sans-serif; font-size: 1.5rem; font-weight: 700; margin-bottom: 1rem;}
.tech-text { font-size: 0.92rem; color: var(--text-secondary); margin-bottom: 0.85rem; line-height: 1.6;}
.tech-text strong { color: var(--text-primary);}
.tech-stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem;}
.stat-box { background: rgba(0, 0, 0, 0.35); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); padding: 1.25rem; text-align: center; display: flex; flex-direction: column; gap: 0.35rem;}
.stat-number { font-family: 'Outfit', sans-serif; font-size: 1.75rem; font-weight: 800; color: #34d399;}
.stat-label { font-size: 0.75rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase;}
/* Footer */.footer { border-top: 1px solid var(--border-subtle); background: rgba(10, 15, 13, 0.9); padding: 2rem 1.5rem; text-align: center; font-size: 0.85rem; color: var(--text-muted);}
.footer-container { max-width: 1280px; margin: 0 auto; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 1rem;}
@media (max-width: 640px) { .footer-container { flex-direction: column; }}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>ScratchNet β 7-Class Flower Image Detector & AI Classifier</title> <meta name="description" content="AI Flower Classifier powered by a deep Convolutional Neural Network (PyTorch). Detect Daisy, Dandelion, Rose, Sunflower, Tulip, Bellflower, and Lotus in real-time."> <link rel="preconnect" href="https://fonts.googleapis.com"> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> <link href="https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap" rel="stylesheet"> <link rel="stylesheet" href="/static/style.css"></head><body> <div class="background-ambient"> <div class="glow-orb orb-1"></div> <div class="glow-orb orb-2"></div> <div class="glow-orb orb-3"></div> </div>
<!-- Main Navigation Bar --> <header class="navbar"> <div class="nav-container"> <div class="brand"> <span class="brand-icon">πͺ·</span> <div class="brand-text"> <span class="brand-name">ScratchNet <span class="brand-ai">AI</span></span> <span class="brand-tag">Botanical CNN Vision</span> </div> </div> <div class="nav-actions"> <div class="status-badge" id="hardwareStatusBadge" title="Hardware Acceleration Status"> <span class="status-dot"></span> <span id="hardwareStatusText">Checking Hardware...</span> </div> <a href="#howToUseSection" class="btn-ghost" id="howToUseNavBtn"> <span>π How to Use Model</span> </a> </div> </div> </header>
<main class="main-content"> <!-- Hero Header --> <section class="hero-section"> <div class="hero-badge"> <span class="badge-sparkle">β¨</span> <span>PyTorch 2D CNN β’ 7 Flower Classes β’ 150Γ150 Spatial Architecture</span> </div> <h1 class="hero-title"> Detect & Identify Flowers with <span class="gradient-text">Deep Learning</span> </h1> <p class="hero-subtitle"> Upload or drag any flower image to classify between <strong>Daisy, Dandelion, Rose, Sunflower, Tulip, Bellflower,</strong> and <strong>Lotus</strong> with instant confidence scores and botanical profiles. </p> </section>
<!-- Quick Sample Selector Carousel --> <section class="samples-section"> <div class="samples-header"> <span class="samples-label">β‘ Quick Test With 1-Click Samples:</span> <span class="samples-hint">Click any flower below to detect instantly</span> </div> <div class="samples-grid" id="samplesContainer"> <!-- Injected via JavaScript from /api/samples --> <div class="sample-skeleton">Loading sample flowers...</div> </div> </section>
<!-- Interactive Workbench Grid --> <section class="workbench-grid"> <!-- Left Panel: Image Upload & Dropzone --> <div class="panel-card upload-panel"> <div class="panel-header"> <h2 class="panel-title"> <span class="panel-icon">πΈ</span> Input Flower Photo </h2> <span class="panel-badge">RGB 150Γ150 Normalization</span> </div>
<!-- Dropzone Area --> <div class="dropzone" id="dropzone" tabindex="0" role="button" aria-label="Upload flower image"> <input type="file" id="fileInput" accept="image/png, image/jpeg, image/webp, image/bmp" style="display: none;"> <div class="dropzone-empty" id="dropzoneEmpty"> <div class="dropzone-icon-ring"> <svg class="upload-svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> <path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path> <polyline points="17 8 12 3 7 8"></polyline> <line x1="12" y1="3" x2="12" y2="15"></line> </svg> </div> <h3 class="dropzone-title">Drag & drop your flower photo here</h3> <p class="dropzone-desc">Supports JPG, PNG, WEBP, BMP up to 20MB</p> <div class="dropzone-actions"> <button type="button" class="btn-primary" id="browseFilesBtn"> <span>Browse Files</span> </button> <span class="paste-hint">or press <kbd>Ctrl</kbd> + <kbd>V</kbd> to paste</span> </div> </div>
<!-- Image Preview (Hidden by default) --> <div class="dropzone-preview" id="dropzonePreview" style="display: none;"> <div class="preview-wrapper"> <img id="previewImage" alt="Uploaded flower preview"> <div class="preview-overlay"> <button type="button" class="btn-icon" id="clearImageBtn" title="Remove image"> <svg viewBox="0 0 24 24" width="18" height="18" stroke="currentColor" stroke-width="2" fill="none"> <line x1="18" y1="6" x2="6" y2="18"></line> <line x1="6" y1="6" x2="18" y2="18"></line> </svg> </button> </div> </div> <div class="preview-meta"> <span class="preview-filename" id="previewFilename">image.jpg</span> <span class="preview-filesize" id="previewFilesize">-- KB</span> </div> </div> </div>
<!-- Analysis Action Trigger --> <div class="upload-controls"> <button type="button" class="btn-submit" id="analyzeBtn" disabled> <span class="btn-spinner" id="btnSpinner" style="display: none;"></span> <span id="analyzeBtnText">Analyze Flower</span> <span class="btn-arrow">β</span> </button> </div> </div>
<!-- Right Panel: Detection Results --> <div class="panel-card result-panel"> <div class="panel-header"> <h2 class="panel-title"> <span class="panel-icon">π¬</span> Detection & Confidence </h2> <span class="panel-badge" id="inferenceDeviceBadge">Ready</span> </div>
<!-- Result Placeholder (When no prediction yet) --> <div class="result-placeholder" id="resultPlaceholder"> <div class="placeholder-art"> <span class="placeholder-emoji">πΊ</span> </div> <h3 class="placeholder-title">Awaiting Flower Photo</h3> <p class="placeholder-desc"> Upload your photo on the left or select any sample flower above to run the neural network. </p> </div>
<!-- Live Results Container (Shown on prediction) --> <div class="result-content" id="resultContent" style="display: none;"> <!-- Primary Winner Card --> <div class="winner-card" id="winnerCard"> <div class="winner-header"> <div class="winner-icon-circle" id="winnerIcon">πΈ</div> <div class="winner-titles"> <span class="winner-tag">Predicted Category</span> <h3 class="winner-name" id="winnerName">Sunflower</h3> <span class="winner-scientific" id="winnerScientific">Helianthus annuus</span> </div> <div class="winner-gauge"> <span class="gauge-value" id="winnerConfidence">99.8%</span> <span class="gauge-label">Confidence</span> </div> </div>
<div class="winner-body"> <p class="winner-description" id="winnerDescription"> A tall, radiant flower celebrated for tracking the sun across the sky. </p> <div class="winner-attributes"> <div class="attr-pill"> <span class="attr-key">Family:</span> <span class="attr-val" id="winnerFamily">Asteraceae</span> </div> <div class="attr-pill"> <span class="attr-key">Blooms:</span> <span class="attr-val" id="winnerSeason">Summer</span> </div> </div> </div> </div>
<!-- 7 Class Probabilities Breakdown --> <div class="probabilities-section"> <h4 class="prob-section-title">Class Probabilities (Softmax Spectrum)</h4> <div class="prob-list" id="probabilitiesList"> <!-- Injected dynamically via app.js --> </div> </div>
<!-- Developer JSON Payload Toggle --> <details class="json-details"> <summary class="json-summary">View Raw API Response (JSON)</summary> <pre class="json-pre"><code id="jsonCodeOutput">{}</code></pre> </details> </div> </div> </section>
<!-- Comprehensive Guide: "How Will Users Use My Model?" --> <section class="guide-section" id="howToUseSection"> <div class="section-title-wrapper"> <span class="section-badge">π Architecture & Deployment Guide</span> <h2 class="section-heading">How Users Can Run & Integrate Your Model</h2> <p class="section-subheading"> Your model is trained, validated, and ready for production. Here are the 4 ways users and developers can consume it: </p> </div>
<div class="guide-cards-grid"> <!-- Card 1: Web Interface --> <div class="guide-card"> <div class="guide-icon-bubble">π</div> <h3 class="guide-card-title">1. Interactive Web App (Current)</h3> <p class="guide-card-desc"> Run this local web application. Anyone on your local network or Wi-Fi can open it in their browser and drag-and-drop photos. </p> <div class="code-snippet"> <code># Start the web serverpy app.py# Or run with host 0.0.0.0 to share on local Wi-Fi</code> </div> </div>
<!-- Card 2: REST API --> <div class="guide-card"> <div class="guide-icon-bubble">β‘</div> <h3 class="guide-card-title">2. REST API for Web & Mobile Apps</h3> <p class="guide-card-desc"> Developers can send HTTP POST requests with any image to your FastAPI endpoint to get instant JSON predictions. </p> <div class="code-snippet"> <code>curl -X POST "http://localhost:8000/api/predict" \ -F "file=@my_flower.jpg"</code> </div> </div>
<!-- Card 3: Python Package --> <div class="guide-card"> <div class="guide-icon-bubble">π</div> <h3 class="guide-card-title">3. Direct Python Import</h3> <p class="guide-card-desc"> Import your trained model into any Python script, data science notebook, or batch processing pipeline. </p> <div class="code-snippet"> <code>from model import predict_flower
result = predict_flower("flower.jpg")print(result["top_flower"], result["confidence_pct"])</code> </div> </div>
<!-- Card 4: Free Cloud Deployment --> <div class="guide-card"> <div class="guide-icon-bubble">π</div> <h3 class="guide-card-title">4. Free Cloud Hosting (Hugging Face)</h3> <p class="guide-card-desc"> Deploy your model for free to <strong>Hugging Face Spaces</strong> or <strong>Render</strong> so anyone in the world can use it via public URL. </p> <div class="code-snippet"> <code># Launch the included Gradio interfacepy gradio_app.py# Push to Hugging Face Spaces for 24/7 public access</code> </div> </div> </div> </section>
<!-- Technical Deep-Dive: Architecture & History --> <section class="tech-section"> <div class="tech-card"> <div class="tech-card-content"> <h3 class="tech-title">From NumPy MLP to PyTorch CNN: The Engineering Story</h3> <p class="tech-text"> The project originated as <strong>ScratchNet</strong>, an MLP written in pure NumPy. While the MLP achieved 90% training accuracy, it flattened images into 67,500 1D vectors, losing all spatial geometry and dropping to 40% on real-world photos due to background color memorization. </p> <p class="tech-text"> Switching to this <strong>PyTorch Convolutional Neural Network</strong> solved the issue: 3 hierarchical convolutional blocks extract invariant edge and petal textures, while MaxPooling downsamples spatial dimensions (150 → 75 → 37 → 18). The model achieved a robust <strong>~79% test accuracy</strong> across 2,240 test images on the 7 flower classes. </p> </div> <div class="tech-stats-grid"> <div class="stat-box"> <span class="stat-number">7</span> <span class="stat-label">Flower Classes</span> </div> <div class="stat-box"> <span class="stat-number">150Γ150</span> <span class="stat-label">RGB Resolution</span> </div> <div class="stat-box"> <span class="stat-number">~79%</span> <span class="stat-label">Test Accuracy</span> </div> <div class="stat-box"> <span class="stat-number">21.6 MB</span> <span class="stat-label">Model Weights</span> </div> </div> </div> </section> </main>
<!-- Footer --> <footer class="footer"> <div class="footer-container"> <div class="footer-brand"> <span>πͺ· ScratchNet AI β Deep Learning Flower Classifier</span> </div> <div class="footer-credits"> <span>Created with PyTorch, FastAPI & Vanilla Modern Web Standards</span> </div> </div> </footer>
<script src="/static/app.js"></script></body></html>.gitattributesAdded+1
.gitignore+2-1
README.md+140-1
app.pyAdded+198
flower_classifier.pthAdded+3
gradio_app.pyAdded+84
model.pyAdded+275
predict.pyAdded+57
requirements.txtAdded+5
run_app.batAdded+14
static/app.jsAdded+316
static/samples/bellflower.jpgAdded

static/samples/daisy.jpgAdded

static/samples/dandelion.jpgAdded

static/samples/lotus.jpgAdded

static/samples/rose.jpgAdded

static/samples/sunflower.jpgAdded

static/samples/tulip.jpgAdded

static/style.cssAdded+1102
templates/index.htmlAdded+321