Spaces:
Running
Running
Image Encoder Microservice πΌοΈ
Standalone service for vision-language learning
What It Does
Converts any image into:
- β 512-dimensional CLIP embeddings
- β Text representation for LLMs
- β Auto-sends to cosmo-ai for learning
- β Runs on FREE HuggingFace CPU tier
Quick Deploy
Create HuggingFace Space:
- Name:
image-encoder - SDK: Docker
- Hardware: CPU basic (free tier)
- Name:
Upload files from
/image-encoder/folderUpdate
COSMO_AI_URLinapp.pyto your cosmo-ai URLDeploy! β
How It Works
[User uploads image]
β
[image-encoder processes with CLIP]
β
[Converts to embedding + text]
β
[Sends to cosmo-ai /api/feed/vision]
β
[Cosmo-AI stores and learns]
API Usage
Encode Image
import requests
import base64
# Read image
with open("photo.jpg", "rb") as f:
img_data = base64.b64encode(f.read()).decode()
# Encode and send to cosmo-ai
response = requests.post(
"https://YOUR-USERNAME-image-encoder.hf.space/encode",
json={
"image_base64": img_data,
"send_to_cosmo": True # Auto-send to cosmo-ai
}
)
print(response.json())
Upload File
files = {"file": open("image.png", "rb")}
response = requests.post(
"https://YOUR-USERNAME-image-encoder.hf.space/encode/upload",
files=files,
params={"send_to_cosmo": True}
)
Features
β CPU Optimized
- Uses CLIP-vit-base-patch32 (150MB)
- Fast inference on free CPU
- No GPU needed
β Auto Keepalive
- Pings itself every 20 minutes
- Prevents space from sleeping
- Always available
β Cosmo-AI Integration
- Automatic data sending
- Vision feed endpoint
- Learning from visual data
Cosmo-AI Integration
Cosmo-AI now has /api/feed/vision endpoint that:
- β Receives image embeddings
- β Stores up to 1000 images
- β Provides stats and samples
- β Enables vision-language learning
Check stats:
curl https://shubhjn-cosmo-ai.hf.space/api/feed/vision/stats
Architecture
βββββββββββββββββββ ββββββββββββββββββββ
β image-encoder ββββββββΆβ cosmo-ai β
β (CPU Space) β REST β (Main App) β
β β API β β
β β’ CLIP Model β β β’ LLM β
β β’ Encoding β β β’ Chat β
β β’ Keepalive β β β’ Vision Feed β
βββββββββββββββββββ ββββββββββββββββββββ
Free & Independent
- π Both services run on FREE HuggingFace tier
- π No restrictions, no API limits
- π Independent microservices
- βΎοΈ Keepalive prevents sleeping
Deploy and enjoy vision-enabled AI! π