Upload app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import cv2 as cv
|
| 2 |
+
import numpy as np
|
| 3 |
+
import gradio as gr
|
| 4 |
+
|
| 5 |
+
# Görseli siyah-beyaza dönüştüren fonksiyon
|
| 6 |
+
def nostalji(image):
|
| 7 |
+
image = np.array(image)
|
| 8 |
+
gray_image = cv.cvtColor(image, cv.COLOR_BGR2GRAY)# COLOR_BGR2GRAY fonksiyonu 3 katmanlı imgeyi tek katmanlı hale dönüştürür
|
| 9 |
+
return gray_image
|
| 10 |
+
|
| 11 |
+
# Gradio arayüzü oluşturma
|
| 12 |
+
with gr.Blocks() as demo:
|
| 13 |
+
gr.Markdown("# Görseli Siyah Beyaza Çevir!")
|
| 14 |
+
gr.Markdown("Bir resim yükleyin ve siyah beyaza çevrilsin!")
|
| 15 |
+
|
| 16 |
+
image_input = gr.Image(type='pil', label="Girdi Görseli")
|
| 17 |
+
image_output = gr.Image(type="numpy", label="Sonuç Görseli")
|
| 18 |
+
|
| 19 |
+
# Bileşenleri fonksiyonla bağlama
|
| 20 |
+
btn = gr.Button("Çevir")
|
| 21 |
+
btn.click(fn=nostalji, inputs=image_input, outputs=image_output)
|
| 22 |
+
|
| 23 |
+
# Gradio arayüzünü başlatma
|
| 24 |
+
if __name__ == "__main__":
|
| 25 |
+
|
| 26 |
+
demo.launch(share=True)
|