Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,10 +9,11 @@ def install_model(namemodel,tokenn,namemodelonxx):
|
|
| 9 |
def convert_to_onnx(model,namemodelonxx):
|
| 10 |
vocab_size = model.text_encoder.embed_tokens.weight.size(0)
|
| 11 |
example_input = torch.randint(0, vocab_size, (1, 100), dtype=torch.long)
|
|
|
|
| 12 |
torch.onnx.export(
|
| 13 |
model, # The model to be exported
|
| 14 |
example_input, # Example input for the model
|
| 15 |
-
|
| 16 |
opset_version=11, # Use an appropriate ONNX opset version
|
| 17 |
input_names=['input'], # Name of the input layer
|
| 18 |
output_names=['output'], # Name of the output layer
|
|
@@ -21,7 +22,7 @@ def convert_to_onnx(model,namemodelonxx):
|
|
| 21 |
'output': {0: 'batch_size'}
|
| 22 |
}
|
| 23 |
)
|
| 24 |
-
return
|
| 25 |
with gr.Blocks() as demo:
|
| 26 |
with gr.Row():
|
| 27 |
with gr.Column():
|
|
|
|
| 9 |
def convert_to_onnx(model,namemodelonxx):
|
| 10 |
vocab_size = model.text_encoder.embed_tokens.weight.size(0)
|
| 11 |
example_input = torch.randint(0, vocab_size, (1, 100), dtype=torch.long)
|
| 12 |
+
x=f"{namemodelonxx}.onnx"
|
| 13 |
torch.onnx.export(
|
| 14 |
model, # The model to be exported
|
| 15 |
example_input, # Example input for the model
|
| 16 |
+
x, # The filename for the exported ONNX model
|
| 17 |
opset_version=11, # Use an appropriate ONNX opset version
|
| 18 |
input_names=['input'], # Name of the input layer
|
| 19 |
output_names=['output'], # Name of the output layer
|
|
|
|
| 22 |
'output': {0: 'batch_size'}
|
| 23 |
}
|
| 24 |
)
|
| 25 |
+
return x
|
| 26 |
with gr.Blocks() as demo:
|
| 27 |
with gr.Row():
|
| 28 |
with gr.Column():
|