Lagrange Dao
  • Introduction
  • Getting Started
    • Build and push your Docker image
    • How to Use the Test Environment
  • Space
    • Intro
      • Lagrange Definition Language(LDL)
      • Lagrange-cli
    • Create Space
    • Build Space
      • Option 1: Langrange-cli
      • Option 2: Web Interface
    • Fork Space
    • Run Space
    • Space Settings
      • Instance Type
      • Space Hardware
    • Use Case
  • Datasets
    • Data Card
  • Models
  • Case Study
    • Stable Diffusion
      • How to Build Stable Diffusion Space
      • How to Integrate Stable Diffusion via Inference API
    • Diffuser/Transformer
      • How to Integrate Diffuser/Transformer
  • Decentralized Auction Marketplace
    • Auction Engine
    • Bidding Task State Machine
    • Reputation System
  • Security
    • Access Tokens
  • Token
  • Mars Testnet
    • Before You Get Started
    • Computing Provider Setup
    • Building Space
    • Using Space
    • Case Study
    • FAQ
  • API Reference
Powered by GitBook
On this page
  • How to Fork the Space and Deploy it:
  • How to Change Models
  1. Case Study
  2. Diffuser/Transformer

How to Integrate Diffuser/Transformer

PreviousDiffuser/TransformerNextDecentralized Auction Marketplace

Last updated 8 months ago

How to Fork the Space and Deploy it:

1. Visit [] and log in to your account

2. Visit the , and click on the [Fork] button to create a duplicate of the Base Space.

3. You can either click on the [Just Fork, choose config later] or select your preferred hardware, and proceed with the payment.

It's recommended to choose "config later" if you anticipate adding more models to your Space in the future to avoid unnecessary redeployments.

In your forked Space, you can click the [Settings] button and scroll down to the Rename section to rename your Space.

Note: Please note that after you change the Space name, the Space link will also be updated. Make sure to share the new link with others as needed.

How to Change Models

In this tutorial, you will learn how to change models within your Diffuser/Transformer Space to meet your specific needs. We will be using the example of changing a model for the "Image-to-Text" task. Follow these steps:

Step 1: Choose a New Model

2.In the library list, select either "Transformers" or "Diffusers," depending on your requirements.

3.In the task list, choose the specific model type you want. For this tutorial, we'll use "Image-to-Text" as an example.

Refine your search criteria to find a model that meets your requirements. Once you have identified the model you want to use, copy its name.

Step 2: Update Your Lagrange Space

1.Go to the Space that you've forked before

2.Navigate to "Files and Versions." Locate the file named "model-setting.json" and open it.

3.Inside this JSON file, replace the existing model name with the one you copied from the Hugging Face Model Hub.

4.Save the changes to the JSON file.

5.After updating the model name, redeploy your Space following Building Space

Once the deployment is complete, you can access the new model through the Inference Endpoint, which has been updated with the selected model.

import requests

API_URL = "https://24lhiquaxn.meta.crosschain.computer"


def query(filename):
    with open(filename, "rb") as f:
        data = f.read()
    response = requests.post(API_URL, data=data)
    return response.json()


output = query("cats.jpg")
print(output)
async function query(filename) {
    const data = fs.readFileSync(filename);
    const response = await fetch(
        "https://24lhiquaxn.meta.crosschain.computer",
        {
            method: "POST",
            body: data,
        }
    );
    const result = await response.json();
    return result;
}

query("cats.jpg").then((response) => {
    console.log(JSON.stringify(response));
});
 curl  https://24lhiquaxn.meta.crosschain.computer \
    -X POST \
    --data-binary '@cats.jpg'

1.Visit the Hugging Face Model Hub at .

Click to check the Sample Space.

https://huggingface.co/models
here
https://lagrange.computer/spaces
Base Space