File size: 1,027 Bytes
45a3202
821310d
45a3202
821310d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45a3202
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
import gradio as gr
from main import suspected_coin_name, user_image_path  # or refactor main logic into functions

def analyze_coin(coin_name, image):
    with open("uploaded_image.jpg", "wb") as f:
        f.write(image.read())

    # Assign file path to global variable for downstream logic
    global user_image_path, suspected_coin_name
    user_image_path = "uploaded_image.jpg"
    suspected_coin_name = coin_name

    # Import and re-run main logic
    import main  # assumes main logic runs on import

    return f"Uploaded {coin_name} and processed. See terminal or logs for detailed output."

interface = gr.Interface(
    fn=analyze_coin,
    inputs=[
        gr.Textbox(label="Enter the Coin Name (e.g. 1955 Lincoln Cent DDO-001)"),
        gr.File(label="Upload a Coin Image")
    ],
    outputs="text",
    title="Coin Expert - AI Coin Identifier",
    description="Upload a photo of a suspected error coin and enter what you think it is. We'll try to match it and tell you if it's real."
)

interface.launch()