hf_mirrors/Promt-generator
Model Introduction
Files & versions
Analysis

Usage in openmind

from openmind import AutoModelForCausalLM, AutoTokenizer
from openmind import is_torch_npu_available, pipeline
import torch
import argparse
import torch.nn.functional as F
import time

def parse_args():
    parser = argparse.ArgumentParser()
    parser.add_argument(
        "--model_name_or_path",
        "-m",
        type=str,
        help="Path to model",
        default="huangjingwang/Promt-generator",
    )
    args = parser.parse_args()
    return args

def main():
    args = parse_args()
    model_path = args.model_name_or_path

    if is_torch_npu_available():
        device = "npu:0"
    else:
        device = "cpu"  
    #device = "cpu"  
    start_time = time.time()
    tokenizer = AutoTokenizer.from_pretrained(model_path )
    model = AutoModelForCausalLM.from_pretrained(model_path ).to(device)
    
    prompt = "a red car"
    inputs = tokenizer(prompt, return_tensors="pt").to(device)
    outputs = model.generate(**inputs)
    generated_prompt = tokenizer.decode(outputs[0], skip_special_tokens=True)
    
    print(f"生成结果: {generated_prompt }")
    end_time = time.time()
    print(f"硬件环境:{device},推理执行时间:{end_time - start_time}秒")


if __name__ == "__main__":
    main()

Model Card: UnfilteredAI/Promt-generator

Model Overview

The UnfilteredAI/Promt-generator is a text generation model designed specifically for creating prompts for text-to-image models. It leverages PyTorch and safetensors for optimized performance and storage, ensuring that it can be easily deployed and scaled for prompt generation tasks.

Intended Use

This model is primarily intended for:

  • Prompt generation for text-to-image models.
  • Creative AI applications where generating high-quality, diverse image descriptions is critical.
  • Supporting AI artists and developers working on generative art projects.

How to Use

To generate prompts using this model, follow these steps:

  1. Load the model in your PyTorch environment.
  2. Input your desired parameters for the prompt generation task.
  3. The model will return text descriptions based on the input, which can then be used with text-to-image models.

Example Code:

from transformers import AutoModelForCausalLM, AutoTokenizer

tokenizer = AutoTokenizer.from_pretrained("UnfilteredAI/Promt-generator")
model = AutoModelForCausalLM.from_pretrained("UnfilteredAI/Promt-generator")

prompt = "a red car"
inputs = tokenizer(prompt, return_tensors="pt")
outputs = model.generate(**inputs)
generated_prompt = tokenizer.decode(outputs[0], skip_special_tokens=True)

print(generated_prompt)