Text Generation
Transformers
Safetensors
English
pegasus
text2text-generation
hunmaniser
ai
aidetection
paraphrasing
nlp
Instructions to use varocarras/Humaneyes with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use varocarras/Humaneyes with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="varocarras/Humaneyes")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForSeq2SeqLM tokenizer = AutoTokenizer.from_pretrained("varocarras/Humaneyes") model = AutoModelForSeq2SeqLM.from_pretrained("varocarras/Humaneyes", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use varocarras/Humaneyes with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "varocarras/Humaneyes" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "varocarras/Humaneyes", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/varocarras/Humaneyes
- SGLang
How to use varocarras/Humaneyes with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "varocarras/Humaneyes" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "varocarras/Humaneyes", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "varocarras/Humaneyes" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "varocarras/Humaneyes", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use varocarras/Humaneyes with Docker Model Runner:
docker model run hf.co/varocarras/Humaneyes
Upload main.py with huggingface_hub
Browse files123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117import gradio as grimport torchfrom transformers import PegasusForConditionalGeneration, PegasusTokenizerimport reimport os
def load_model(): """Load the model from local storage""" torch_device = 'cuda' if torch.cuda.is_available() else 'cpu' print(f"Using device: {torch_device}")
# Load tokenizer and model from local directory tokenizer = PegasusTokenizer.from_pretrained('./models') model = PegasusForConditionalGeneration.from_pretrained('./models').to(torch_device) return tokenizer, model, torch_device
def split_into_paragraphs(text): """Split text into paragraphs while preserving empty lines.""" paragraphs = text.split('\n\n') return [p.strip() for p in paragraphs if p.strip()]
def split_into_sentences(paragraph): """Split paragraph into sentences using regex.""" sentences = re.split(r'(?<=[.!?])\s+', paragraph) return [s.strip() for s in sentences if s.strip()]
def get_response(input_text, num_return_sequences, tokenizer, model, torch_device): batch = tokenizer.prepare_seq2seq_batch( [input_text], truncation=True, padding='longest', max_length=80, return_tensors="pt" ).to(torch_device)
translated = model.generate( **batch, num_beams=10, num_return_sequences=num_return_sequences, temperature=1.0, repetition_penalty=2.8, length_penalty=1.2, max_length=80, min_length=5, no_repeat_ngram_size=3 )
tgt_text = tokenizer.batch_decode(translated, skip_special_tokens=True) return tgt_text[0]
def get_response_from_text(context, tokenizer, model, torch_device): """Process entire text while preserving paragraph structure.""" paragraphs = split_into_paragraphs(context) paraphrased_paragraphs = []
for paragraph in paragraphs: sentences = split_into_sentences(paragraph) paraphrased_sentences = []
for sentence in sentences: if len(sentence.split()) < 3: paraphrased_sentences.append(sentence) continue
try: paraphrased = get_response(sentence, 1, tokenizer, model, torch_device) if not any(phrase in paraphrased.lower() for phrase in ['it\'s like', 'in other words']): paraphrased_sentences.append(paraphrased) else: paraphrased_sentences.append(sentence) except Exception as e: print(f"Error processing sentence: {e}") paraphrased_sentences.append(sentence)
paraphrased_paragraphs.append(' '.join(paraphrased_sentences))
return '\n\n'.join(paraphrased_paragraphs)
def create_interface(): """Create and configure the Gradio interface""" # Load model and tokenizer tokenizer, model, torch_device = load_model()
def greet(context): return get_response_from_text(context, tokenizer, model, torch_device)
# Create interface with improved styling iface = gr.Interface( fn=greet, inputs=gr.Textbox( lines=15, label="Input Text", placeholder="Enter your text here...", elem_classes="input-text" ), outputs=gr.Textbox( lines=15, label="Paraphrased Text", elem_classes="output-text" ), title="Advanced Text Paraphraser", description="Enter text to generate a high-quality paraphrased version while maintaining paragraph structure.", theme="default", css=""" .input-text, .output-text { font-size: 16px !important; font-family: Arial, sans-serif !important; min-height: 300px !important; } """ ) return iface
if __name__ == "__main__": # Create and launch the interface interface = create_interface() interface.launch()main.pyAdded+117