File size: 1,801 Bytes
7efd637
5e6f5c8
7efd637
5e6f5c8
 
 
 
 
 
 
7efd637
5e6f5c8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7efd637
5e6f5c8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7efd637
5e6f5c8
7efd637
5e6f5c8
 
 
 
 
7efd637
5e6f5c8
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import gradio as gr
import random

def generate_app(image):
    # Placeholder function for app generation
    # In a real scenario, this would involve image analysis and code generation
    components = ["Header", "Sidebar", "MainContent", "Footer"]
    code = f"""
import React from 'react';
import {{ {', '.join(components)} }} from './components';

function App() {{
  return (
    <div className="app">
      {' '.join(f'<{component} />' for component in components)}
    </div>
  );
}}

export default App;
    """
    return code

with gr.Blocks() as demo:
    gr.Markdown("# Turn your wireframe into an app")
    gr.Markdown("Upload an image of your website design and we'll build it for you with React + Tailwind.")
    
    with gr.Row():
        with gr.Column(scale=2):
            with gr.Row():
                napkin_img = gr.Image(value="path/to/napkin_sketch.png", label="Napkin")
                react_img = gr.Image(value="path/to/react_app.png", label="React app")
            
            file_output = gr.File(label="Download React App")
        
        with gr.Column():
            image_input = gr.Image(label="Upload a screenshot", elem_id="image_upload")
            example_link = gr.Markdown("Need an example image? [Try ours](#).")
            
            model_dropdown = gr.Dropdown(
                choices=["Llama 3.2 90B Vision", "Other models..."],
                value="Llama 3.2 90B Vision",
                label="AI Model"
            )
            
            generate_button = gr.Button("Generate app", variant="primary")
    
    code_output = gr.Code(language="javascript", label="Generated React Code")
    
    generate_button.click(
        fn=generate_app,
        inputs=[image_input],
        outputs=[code_output, file_output]
    )

demo.launch()