Gradio'da Başlığa Logo Ekleme

 Bu yazıda Gradio'da title kısmına nasıl logo ekleyebileceğini göstereceğim. 


1.Yol: Gradio Blocks ile:

import gradio as gr

with gr.Blocks() as demo:
  with gr.Row():
    with gr.Column(scale=1):
        None
    with gr.Column(scale=1, variant="default"):
        gr.HTML("""<div id='output_image' style='display:block; 
                  margin-left: auto; margin-right: auto;
                  align-items: center; justify-content: center;'></div>""")
        result = gr.Image("logo.png",
                        label=None, show_label=False, height=150, elem_id="output_image",
                        show_download_button=False, container=False)
    with gr.Column(scale=1):
        None

2.Yol: Gradio Interface ile:

import base64
import gradio as gr

with open("logo.png", "rb") as f:
    logo_base64 = base64.b64encode(f.read()).decode()
title_with_logo = f"""YOUR TITLE
                    <img src="data:image/jpeg;base64,{logo_base64}" 
                    width="125" style='display:block; 
                    margin-left: auto; margin-right: auto; padding-top: 1ch; 
                    align-items: center; justify-content: center;'>"""  

interface = gr.Interface(
    title=title_with_logo,
    fn=your_result_function,
    inputs=gr.Image(),
    outputs='image',
)

interface.launch()
Paylaş:

Ara