|
import gradio as gr |
|
from PIL import Image, ImageDraw |
|
import requests |
|
from io import BytesIO |
|
import numpy as np |
|
|
|
|
|
input_image_url = "https://raw.githubusercontent.com/xoghd1126/G4-finalproject/main/Slide-1.png" |
|
response = requests.get(input_image_url) |
|
image = Image.open(BytesIO(response.content)) |
|
|
|
|
|
image_np = np.array(image) |
|
|
|
|
|
output_image_url = "https://raw.githubusercontent.com/xoghd1126/G4-finalproject/main/Slide-2.png" |
|
|
|
|
|
def process_drawing(drawing): |
|
|
|
response = requests.get(output_image_url) |
|
output_image = Image.open(BytesIO(response.content)) |
|
|
|
return output_image |
|
|
|
|
|
def create_interface(): |
|
sketchpad = gr.Sketchpad(label="Draw lines to match items", type="numpy", value=image_np) |
|
|
|
interface = gr.Interface( |
|
fn=process_drawing, |
|
inputs=[sketchpad], |
|
outputs="image", |
|
title="Match the words with the appropriate verb tense" |
|
) |
|
return interface |
|
|
|
|
|
interface = create_interface() |
|
interface.launch() |