File size: 946 Bytes
cfc7f91
982c89f
cfc7f91
b5e31dc
982c89f
cfc7f91
b5e31dc
506dcd4
b5e31dc
506dcd4
982c89f
 
 
 
b5e31dc
982c89f
b5e31dc
 
982c89f
b5e31dc
982c89f
 
 
 
 
906cc8b
982c89f
b5e31dc
982c89f
b5e31dc
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import gradio as gr
from transformers import pipeline

# Initialize the pipeline
pipe = pipeline("visual-question-answering", model="openbmb/MiniCPM-Llama3-V-2_5", trust_remote_code=True)

# Define the Gradio components
image = gr.Image(type="pil", label="Image")
question = gr.Textbox(value="Using the standard 9x9 sudoku format, solve the sudoku puzzle in the image correctly.", label="Question")
answer = gr.Textbox(label="Answer", show_label=True, show_copy_button=True)

title = "Sudoku Solver by FG"
description = "Sudoku Solver using MiniCPM-Llama3-V-2_5"

# Define the function for solving Sudoku
def solve_sudoku(image, question):
    result = pipe(image, question)
    return result[0]['answer']

# Create the Gradio interface
demo = gr.Interface(
    fn=solve_sudoku,
    inputs=[image, question],
    outputs=answer,
    title=title,
    description=description,
    theme="compact",
)

# Launch the interface
demo.launch(share=True)