Coder Social home page Coder Social logo

herbras / ekstraksi-warna-api Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 3 KB

API ini digunakan untuk mengekstrak warna dominan dari gambar yang diberikan melalui URL. API ini menggunakan k-means clustering untuk mengekstrak warna dan mengembalikannya dalam format HEX.

Home Page: https://warna.qlm.one/extract_colors/

Python 100.00%

ekstraksi-warna-api's Introduction

Dokumentasi API: Extract Colors

LIVE ๐Ÿ˜บ

warna.qlm.one/extract_colors

Deskripsi

API ini digunakan untuk mengekstrak warna dominan dari gambar yang diberikan melalui URL. API ini menggunakan k-means clustering untuk mengekstrak warna dan mengembalikannya dalam format HEX.

Kredit

Algoritma k-means untuk ekstraksi palet diadaptasi dari kode oleh Mas Aria Ghora di artikelnya yang dapat ditemukan di sini.

Cara Penggunaan

Instalasi Dependensi

Sebelum menjalankan API, pastikan untuk menginstal semua pustaka yang dibutuhkan dengan menjalankan:

pip install -r requirements.txt

Menjalankan API

Untuk menjalankan API, jalankan perintah berikut:

uvicorn main:app --host 0.0.0.0 --port 8000

Endpoint

POST /extract_colors/

Deskripsi

Menerima URL gambar dan mengembalikan 6 warna dominan dalam format HEX.

Request Body

Model Pydantic ImageUrl berisi satu field:

  • image_url: URL gambar yang ingin diolah (Harus dimulai dengan "http://" atau "https://").

Contoh:

{
    "image_url": "https://example.com/image.jpg"
}
Responses
HTTP 200

Array dari warna dominan dalam format HEX.

Contoh:

{
    "warna_dominan": ["#FFFFFF", "#000000", "#FF5733", "#33FF57", "#4B0082", "#800080"]
}
HTTP 400

Invalid URL atau Unsupported file type.

Contoh:

{
    "detail": "Invalid URL"
}
HTTP 500

Server error atau kegagalan lainnya.

Contoh:

{
    "detail": "Internal Server Error"
}

Contoh Request Menggunakan curl

curl --request POST \
  --url http://localhost:8000/extract_colors/ \
  --header 'Content-Type: application/json' \
  --data '{
    "image_url": "https://example.com/image.jpg"
}'

ekstraksi-warna-api's People

Contributors

herbras avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.