Η KARATARAKIS παρέχει ολοκληρωμένες υπηρεσίες φιλοξενίας, γαστρονομίας, αναψυχής & διασκέδασης, καθώς και υπηρεσίες οργάνωσης και διεκπεραίωσης κοινωνικών και εμπορικών εκδηλώσεων.
Platform recommendation systems prioritize high‑engagement visuals, reinforcing the dominance of certain clusters (e.g., Street‑Wear Fusion). Consequently, niche or regionally specific styles risk marginalisation—a digital echo of the “visibility gap” identified by Gillespie (2022).
Then replace the get_top_image_urls body with something like: ngintip jilbab pipisblpraljml3lgngv0jiyvwdxq8 images top
def get_top_image_urls_google(query: str, top_n: int = 10) -> List[str]:
api_key = os.getenv("GOOGLE_API_KEY")
cse_id = os.getenv("GOOGLE_CSE_ID")
url = "https://www.googleapis.com/customsearch/v1"
params =
"key": api_key,
"cx": cse_id,
"searchType": "image",
"q": query,
"num": top_n,
"safe": "high", # or "off"
resp = requests.get(url, params=params, timeout=10)
resp.raise_for_status()
data = resp.json()
return [item["link"] for item in data.get("items", [])]
The rest of the FastAPI wrapper stays identical – just import the Google version instead of the Bing one. The rest of the FastAPI wrapper stays identical
If you need the raw files (e.g., to cache them or run a classifier), add a small helper: If you need the raw files (e
import pathlib
import shutil
def download_images(urls: List[str], dest_dir: str = "./downloaded_images") -> List[pathlib.Path]:
"""
Download each image URL to ``dest_dir``. Returns list of pathlib.Path objects.
"""
pathlib.Path(dest_dir).mkdir(parents=True, exist_ok=True)
saved_paths = []
for idx, url in enumerate(urls, 1):
try:
resp = requests.get(url, stream=True, timeout=8)
resp.raise_for_status()
# Guess a simple filename – you can improve with content‑type detection
ext = pathlib.Path(url).suffix.split("?")[0] or ".jpg"
filename = f"img_idx:03dext"
out_path = pathlib.Path(dest_dir) / filename
with open(out_path, "wb") as f:
shutil.copyfileobj(resp.raw, f)
saved_paths.append(out_path)
except Exception as e:
print(f"⚠️ Failed to download url: e")
return saved_paths
Use it like:
urls = get_top_image_urls("jilbab", top_n=5)
downloaded = download_images(urls, "./jilbab_samples")
print("Saved:", downloaded)
pip install requests fastapi uvicorn python-dotenv
BING_SEARCH_KEY=YOUR_BING_SUBSCRIPTION_KEY
BING_SEARCH_ENDPOINT=https://YOUR_RESOURCE_NAME.cognitiveservices.azure.com/