Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from PIL import Image, ImageDraw
|
3 |
+
import requests
|
4 |
+
from io import BytesIO
|
5 |
+
import numpy as np
|
6 |
+
|
7 |
+
# Load the image from the URL
|
8 |
+
input_image_url = "https://raw.githubusercontent.com/xoghd1126/G4-finalproject/main/%EC%8A%AC%EB%9D%BC%EC%9D%B4%EB%93%9C1.PNG"
|
9 |
+
response = requests.get(input_image_url)
|
10 |
+
image = Image.open(BytesIO(response.content))
|
11 |
+
|
12 |
+
# Convert the image to a numpy array
|
13 |
+
image_np = np.array(image)
|
14 |
+
|
15 |
+
# URL of the output image
|
16 |
+
output_image_url = "https://raw.githubusercontent.com/xoghd1126/G4-finalproject/main/%EC%8A%AC%EB%9D%BC%EC%9D%B4%EB%93%9C2.png"
|
17 |
+
|
18 |
+
# Function to process the drawing (dummy processing)
|
19 |
+
def process_drawing(drawing):
|
20 |
+
# Fetch the output image
|
21 |
+
response = requests.get(output_image_url)
|
22 |
+
output_image = Image.open(BytesIO(response.content))
|
23 |
+
|
24 |
+
return output_image
|
25 |
+
|
26 |
+
# Create Gradio interface
|
27 |
+
def create_interface():
|
28 |
+
sketchpad = gr.Sketchpad(label="Draw lines to match items", type="numpy", value=image_np)
|
29 |
+
|
30 |
+
interface = gr.Interface(
|
31 |
+
fn=process_drawing,
|
32 |
+
inputs=[sketchpad],
|
33 |
+
outputs="image", # Correctly specify the output type as "image"
|
34 |
+
title="Match the words with the appropriate verb tense"
|
35 |
+
)
|
36 |
+
return interface
|
37 |
+
|
38 |
+
# Create and launch the interface
|
39 |
+
interface = create_interface()
|
40 |
+
interface.launch()
|