akhaliq HF staff commited on
Commit
de4d170
1 Parent(s): 77aebb7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -14
app.py CHANGED
@@ -60,12 +60,12 @@ def generate_gradio_app(image):
60
  response = client.chat.completions.create(
61
  model="meta-llama/Llama-Vision-Free",
62
  messages=messages,
63
- max_tokens=50000,
64
  temperature=0.7,
65
  top_p=0.7,
66
  top_k=50,
67
  repetition_penalty=1,
68
- stop=["<|eot_id|>", "<|eom_id|>"],
69
  stream=True
70
  )
71
 
@@ -77,26 +77,19 @@ def generate_gradio_app(image):
77
 
78
  return generated_code
79
  except Exception as e:
80
- return f"An error occurred: {str(e)}"
81
 
82
  with gr.Blocks() as demo:
83
  gr.Markdown("# Turn your wireframe into a Gradio app")
84
  gr.Markdown("Upload an image of your UI design and we'll build a Gradio app for you.")
85
 
86
  with gr.Row():
87
- with gr.Column():
88
  image_input = gr.Image(label="Upload a screenshot", elem_id="image_upload")
89
- example_link = gr.Markdown("Need an example image? [Try ours](https://example.com/wireframe.png).")
90
-
91
- model_dropdown = gr.Dropdown(
92
- choices=["Llama-Vision-Free"],
93
- value="Llama-Vision-Free",
94
- label="AI Model"
95
- )
96
-
97
  generate_button = gr.Button("Generate Gradio app", variant="primary")
98
-
99
- code_output = gr.Code(language="python", label="Generated Gradio Code", lines=30)
 
100
 
101
  generate_button.click(
102
  fn=generate_gradio_app,
 
60
  response = client.chat.completions.create(
61
  model="meta-llama/Llama-Vision-Free",
62
  messages=messages,
63
+ max_tokens=2048,
64
  temperature=0.7,
65
  top_p=0.7,
66
  top_k=50,
67
  repetition_penalty=1,
68
+ stop=["<|im_end|>"],
69
  stream=True
70
  )
71
 
 
77
 
78
  return generated_code
79
  except Exception as e:
80
+ return f"An error occurred: {str(e)}\n\nPlease try again or check your API key and connection."
81
 
82
  with gr.Blocks() as demo:
83
  gr.Markdown("# Turn your wireframe into a Gradio app")
84
  gr.Markdown("Upload an image of your UI design and we'll build a Gradio app for you.")
85
 
86
  with gr.Row():
87
+ with gr.Column(scale=1):
88
  image_input = gr.Image(label="Upload a screenshot", elem_id="image_upload")
 
 
 
 
 
 
 
 
89
  generate_button = gr.Button("Generate Gradio app", variant="primary")
90
+
91
+ with gr.Column(scale=2):
92
+ code_output = gr.Code(language="python", label="Generated Gradio Code", lines=30)
93
 
94
  generate_button.click(
95
  fn=generate_gradio_app,