import gradio as gr import pandas as pd import random import threading import time # --- Load dataset --- df = pd.read_csv("amazon_eco-friendly_products.csv") # --- Clean price column --- def clean_price(price_str): try: if isinstance(price_str, str) and "$" in price_str: return float(price_str.replace("$", "").strip()) return float(price_str) except: return None df["price"] = df["price"].apply(clean_price) df = df.dropna(subset=["price"]) # --- Environmental quotes --- quotes = [ "π Small choices, big changes.", "β»οΈ Every eco-friendly swap plants a seed for tomorrow.", "π± A bamboo brush today keeps plastic away.", "πΏ Be the change you shop for.", "π Plastic lasts 500 years, your choice lasts forever.", "π§ Save water, save life.", "π Renewable is reliable.", "π The Earth doesnβt need more stuff, it needs better stuff.", "π Consume less, choose wise.", "π² A greener choice is a cleaner future.", "π You donβt need to be perfect, just better than yesterday.", "π± One toothbrush less, a million smiles more.", "β»οΈ What you buy today builds tomorrow.", "πΏ Nature is not a place to visit, itβs home.", "π Sustainable is beautiful.", "π Every drop counts; save water, save life.", "π Eco choices today are gifts for tomorrow.", "π Green living is smart living.", "π Protect the planet, protect yourself.", "πΊ A cleaner Earth starts with mindful habits.", "πΎ Small eco steps create huge impact.", "π Go green, think global, act local.", "π₯ Reduce waste, light the path for future generations.", "π Eat consciously, live sustainably.", "πΈ Nature thrives when you choose wisely.", "π Less consumption, more conservation.", "π‘ Energy saved is a planet saved.", "π» Plant trees, grow hope.", "π± Minimalism is sustainability in action.", "π Care for the Earthβitβs the only home we have.", "β»οΈ Waste less, live more.", "πΏ Green habits, brighter future.", "π§ Clean water, clear conscience.", "π Sun-powered is future-powered.", "π Your choices echo through generations.", "π² Forests are worth more than goldβprotect them.", "π Reduce, reuse, rethink.", "πΈ Live lightly, tread softly.", "πΎ Sustainability is love for the next generation.", "π Small actions, massive change." ] # --- Impact messages --- impacts = { "bamboo toothbrush": "By choosing a bamboo brush, you prevent ~4 plastic brushes a year from ending in landfills.", "reusable bottle": "One reusable bottle saves ~1,460 plastic bottles a year.", "eco bag": "A single reusable bag replaces ~700 plastic bags annually.", "solar light": "Solar lights cut down ~90kg COβ emissions per year.", "compostable plates": "Using compostable plates diverts hundreds of plastic plates from landfills yearly.", "beeswax wrap": "Replacing plastic wrap with beeswax saves ~200 feet of plastic wrap per year.", "stainless steel straw": "One reusable straw prevents ~500 plastic straws from polluting oceans annually.", "reusable coffee cup": "Switching to a reusable cup saves ~400 disposable cups yearly.", "LED bulb": "Using LED bulbs reduces ~150kg COβ emissions per year compared to incandescent bulbs.", "bamboo cutlery": "One set of bamboo cutlery prevents ~100 plastic utensils from entering landfills each year.", "recycled notebook": "Using recycled notebooks saves ~12 trees per 100 notebooks produced.", "eco-friendly detergent": "Switching to eco detergent reduces harmful chemicals in water, saving aquatic life.", "solar charger": "Solar chargers reduce dependency on grid electricity, cutting ~100kg COβ annually.", "reusable food container": "One container saves ~200 plastic bags and wraps per year.", "water-saving showerhead": "Water-saving showerheads save ~30,000 liters of water annually per household.", "eco soap": "Using biodegradable soap prevents harmful chemicals from entering rivers and oceans.", "bamboo mat": "Bamboo mats reduce plastic and synthetic mat usage, saving the environment.", "recycled toilet paper": "One roll of recycled toilet paper saves ~17 trees compared to virgin paper.", "energy-efficient appliances": "Switching to energy-efficient appliances reduces electricity consumption significantly.", "organic cotton clothing": "Choosing organic cotton avoids ~5,000 liters of water per kg of fabric.", "plant-based cleaning products": "Plant-based cleaners reduce chemical pollution in water systems.", "reusable sandwich wrap": "One wrap replaces hundreds of single-use plastic sandwich bags yearly.", "eco shampoo bar": "Shampoo bars save ~2 plastic bottles per year per person.", "bamboo hairbrush": "Using a bamboo hairbrush prevents plastic brush pollution in landfills.", "recycled packaging": "Products with recycled packaging save trees and reduce plastic waste.", "biodegradable trash bags": "Switching to biodegradable trash bags reduces plastic landfill waste annually.", "solar water heater": "Solar water heaters reduce electricity demand and cut COβ emissions.", "compost bin": "Composting kitchen waste reduces methane emissions from landfills.", "eco toothpaste": "Eco toothpaste tubes save ~1 plastic tube per person every month.", "reusable menstrual products": "Reusable pads or cups reduce ~240 disposable items per person per year.", "energy-saving power strip": "Using smart strips prevents phantom energy waste from electronics.", "bamboo kitchenware": "Bamboo utensils replace plastic alternatives, reducing landfill waste.", "eco laundry bag": "Using reusable laundry bags reduces microplastic pollution from synthetic clothes.", "recycled pens": "One recycled pen saves ~5 plastic pens from going to landfill.", "bamboo sunglasses": "Bamboo sunglasses reduce reliance on plastic frames, saving the environment.", "solar backpack": "Solar backpacks charge devices sustainably without electricity.", "eco yoga mat": "Eco-friendly yoga mats reduce PVC usage and chemical pollution.", "compostable cutlery": "Switching prevents hundreds of plastic utensils from polluting landfills.", "biodegradable soap wrapper": "Prevents plastic from entering oceans and decomposes naturally.", "recycled water bottle": "Recycled bottles save energy and reduce plastic production.", "bamboo tissue box": "Bamboo alternatives reduce plastic waste and promote sustainable forestry.", "eco dish brush": "Using a bamboo dish brush prevents plastic waste from entering landfills." } # --- State --- shown_products = [] batch_size = 9 # --- Product rendering --- def render_products(products): if products.empty: return "