HErsoy commited on
Commit
02a9c8c
·
verified ·
1 Parent(s): d4508fd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -11
app.py CHANGED
@@ -2,26 +2,26 @@ import cv2 as cv
2
  import numpy as np
3
  import gradio as gr
4
 
5
- def nostalji(image):
6
- # Görüntüyü NumPy dizisine dönüştür
7
  image = np.array(image)
8
- # BGR'den RGB'ye dönüştür (Gradio RGB formatında alır)
9
  image = cv.cvtColor(image, cv.COLOR_RGB2BGR)
10
- # Gri tonlamaya dönüştür
11
  gray_image = cv.cvtColor(image, cv.COLOR_BGR2GRAY)
12
  return gray_image
13
 
14
- # Gradio arayüzü oluşturma
15
  with gr.Blocks() as demo:
16
- gr.Markdown("# Görseli siyah beyaza çevir!")
17
- gr.Markdown("Bir resim yükleyin ve siyah beyaza çevrilsin...")
18
 
19
  image_input = gr.Image(type='pil')
20
- image_output = gr.Image(type="numpy", label="Oluşan Resim")
21
 
22
- # Fonksiyonu gradio bileşenlerine bağlama:
23
- btn = gr.Button("Çevir")
24
- btn.click(fn=nostalji, inputs=image_input, outputs=image_output)
25
 
26
  if __name__ == "__main__":
27
  demo.launch()
 
2
  import numpy as np
3
  import gradio as gr
4
 
5
+ def nostalgic_effect(image):
6
+ # Convert the image to a NumPy array
7
  image = np.array(image)
8
+ # Convert from RGB to BGR (Gradio inputs in RGB, OpenCV works in BGR)
9
  image = cv.cvtColor(image, cv.COLOR_RGB2BGR)
10
+ # Convert to grayscale
11
  gray_image = cv.cvtColor(image, cv.COLOR_BGR2GRAY)
12
  return gray_image
13
 
14
+ # Creating the Gradio interface
15
  with gr.Blocks() as demo:
16
+ gr.Markdown("# Convert Image to Black and White!")
17
+ gr.Markdown("Upload an image and see it transformed to black and white...")
18
 
19
  image_input = gr.Image(type='pil')
20
+ image_output = gr.Image(type="numpy", label="Converted Image")
21
 
22
+ # Connecting the function to Gradio components:
23
+ convert_btn = gr.Button("Convert")
24
+ convert_btn.click(fn=nostalgic_effect, inputs=image_input, outputs=image_output)
25
 
26
  if __name__ == "__main__":
27
  demo.launch()